I\'m very new to CodeIgniter and Active Record in particular, I know how to do this well in normal SQL but I\'m trying to learn.
How can I select some data from one
This goes to you model:
public function count_news_by_category($cat)
{
return $this->db
->where('category', $cat)
->where('is_enabled', 1)
->count_all_results('news');
}
It'a an example from my current project.
According to benchmarking this query works faster than if you do the following:
$this->db->select('*')->from('news')->where(...);
$q = $this->db->get();
return $q->num_rows();