The count_all_results() method is used to get the number of rows in a MySQL result handle.
Permits you to determine the number of rows in a particular Active Record query. Queries will accept Query Builder restrictors such as where(), or_where(), like(), or_like(), etc.
echo $this->db->count_all_results('my_table');
// Produces an integer, like 25
More Example
$this->db->like('category', 'php');
$this->db->from('tbl_post');
echo $this->db->count_all_results();
// Produces an integer, like 17
count_all_results() method also resets any field values that you may have passed to select(). If you need to keep them, you can pass FALSE as the second parameter.
echo $this->db->count_all_results('tbl_user', FALSE);