/** * @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(); }