/** * Get count of all predb rows. */ public function getPreCount($dirname = '', $category = '') { // Only use Sphinx if this is a search request if ($dirname) { if ($this->pdo->getSetting('sphinxenabled') && $this->pdo->getSetting('sphinxindexpredb')) { // Search using Sphinx $sphinx = new Sphinx(); $count = $sphinx->getPreCount($dirname, $category); if ($count > -1) { return $count; } } } $dirname = empty($dirname) ? '' : sprintf("WHERE dirname LIKE %s", $this->pdo->escapeString('%' . $dirname . '%')); $category = empty($category) ? '' : sprintf((empty($dirname) ? 'WHERE' : ' AND') . " category = %s", $this->pdo->escapeString($category)); $predbQuery = $this->pdo->queryOneRow(sprintf('SELECT COUNT(id) AS num FROM predb %s %s', $dirname, $category), true); return $predbQuery['num']; }