CodeIgniter Active Record - Get number of returned rows

Zim picture Zim · Aug 3, 2009 · Viewed 186.6k times · Source

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 of my tables, and then count how many rows are returned using CodeIgniters Active Record class?

Thanks, Tom.

Answer

Residuum picture Residuum · Aug 3, 2009

Have a look at the result functions here:

$this->db->from('yourtable');
[... more active record code ...]
$query = $this->db->get();
$rowcount = $query->num_rows();