[eluser]Karman de Lange[/eluser]
Below should work, Just 1 thing, If you want to use pagination, then this will only return the num of rows in the current result with limited by the limit statement.
you can either do another query counting all rows without the limit statment (as per standard pagination tutorials) or you can use SQL_CALC_FOUND_ROWS which only use 1 query todo both reducing the load on server a bit. . I extended the default mysql drivers to have option for this so shout if you want the code.
Code:
$query = $this->db->get($tablename,$limit,$offset=0);
$num_rows = $query->num_rows();
$rows = $this->db->result_array();
return array('num_rows'=>$num_rows,'rows'=>$row);