/** * Return the number of results for the current query * */ public function count() { //If data has already been selected return the row count if (sizeof($this->all()) > 0) { return sizeof($this->all()); } else { $this->db->from($this->_table()); return $this->db->count_all_results(); } }