public function count_all_results($table = '', $reset = TRUE)
{
if ($table !== '') {
$this->_track_aliases($table);
$this->from($table);
}
// ORDER BY usage is often problematic here (most notably
// on Microsoft SQL Server) and ultimately unnecessary
// for selecting COUNT(*) ...
if (!empty($this->qb_orderby)) {
$orderby = $this->qb_orderby;
$this->qb_orderby = NULL;
}
$result = $this->qb_distinct === TRUE ? $this->query($this->_count_string . $this->protect_identifiers('numrows') . "\nFROM (\n" . $this->_compile_select() . "\n) CI_count_all_results") : $this->query($this->_compile_select($this->_count_string . $this->protect_identifiers('numrows')));
if ($reset === TRUE) {
$this->_reset_select();
} elseif (!isset($this->qb_orderby)) {
$this->qb_orderby = $orderby;
}
if ($result->num_rows() === 0) {
return 0;
}
$row = $result->row();
return (int) $row->numrows;
}