/** * @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()); }
/** * @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(); }
/** * @covers ::joinNestedRels * @expectedException InvalidArgumentException */ public function testJoinRelsError() { $repo = User::getRepo(); $select = new Select($repo); $select->joinRels(['unknown address']); }