Ejemplo n.º 1
0
 /**
  * @covers ::__construct
  * @covers ::getRepo
  */
 public function testConstruct()
 {
     $repo = City::getRepo();
     $select = new Select($repo);
     $this->assertSame($repo, $select->getRepo());
     $this->assertEquals([new SQL\Aliased('City')], $select->getFrom());
     $this->assertEquals([new SQL\Aliased(new SQL\SQL('`City`.*'))], $select->getColumns());
 }
Ejemplo n.º 2
0
 /**
  * @param  int $flags
  * @return string
  */
 public function loadCount($flags = null)
 {
     $repo = $this->getRepo();
     $db = $this->select->getDb();
     $this->applyFlags($flags);
     $table = $db->escapeName($repo->getTable());
     $primaryKey = $db->escapeName($repo->getPrimaryKey());
     $this->select->clearColumns()->column(new SQL("COUNT({$table}.{$primaryKey})"), 'countAll');
     return $this->select->execute()->fetchColumn();
 }
Ejemplo n.º 3
0
 /**
  * @covers ::joinNestedRels
  * @expectedException InvalidArgumentException
  */
 public function testJoinRelsError()
 {
     $repo = User::getRepo();
     $select = new Select($repo);
     $select->joinRels(['unknown address']);
 }