Example #1
0
 public function prepare()
 {
     return $this->stmt ?: ($this->stmt = $this->database->prepare($this->build()));
 }
Example #2
0
 public static function initialize()
 {
     self::$__caches = new \SplObjectStorage();
     self::$__defaultDatabase = Database::getDefault();
     self::__initializeSelectQueries();
     if (defined("self::FOREIGN_KEYS")) {
         self::$__foreignKeys = self::FOREIGN_KEYS;
     }
     if (defined("self::RELATIONS")) {
         self::$__relations = self::RELATIONS;
     }
 }
Example #3
0
 public function testForUpdate()
 {
     $stmt = \Mockery::mock("PDOStatement");
     $select = (new Select())->from("foo")->forUpdate();
     $this->assertEquals("SELECT * FROM `foo` FOR UPDATE", $select->build());
     Database::getDefault()->selectForUpdate = true;
     $select = (new Select())->from("foo")->forUpdate(false);
     $this->assertEquals("SELECT * FROM `foo`", $select->build());
     $cache = null;
     $this->mockDatabase->shouldReceive("prepare")->once("SELECT * FROM `foo` FOR UPDATE")->andReturn($stmt)->globally()->ordered();
     $stmt->shouldReceive("execute")->twice()->with([])->andReturn(true)->globally()->ordered();
     Select::cached($cache)->from("foo")->forUpdate()->run();
     Select::cached($cache)->from("foo")->forUpdate()->run();
 }