[eluser]darkhouse[/eluser]
Yes, there's SQL_CALC_FOUND_ROWS, so you can use a method in your model like this:
Code:
function get_some_records($limit, $offset, &$total_rows){
$this->db->select('SQL_CALC_FOUND_ROWS *', FALSE);
$query = $this->db->get('some_table', $limit, $offset);
$total_rows = $this->db->query('SELECT FOUND_ROWS() total_rows')->row()->total_rows;
return $query->result();
}
And then your controller would be like this:
Code:
function index($page=1){
$limit = 10;
$offset = $limit * ($page - 1);
$total_rows = 0;
$data = array(
'records' => $this->some_model->get_some_records($limit, $offset, $total_rows),
'total_rows' => $total_rows
);
$this->load->view('some_view', $data);
}
However, I believe there's a performance hit when using SQL_CALC_FOUND_ROWS. It might be wiser to just run 2 queries, one with a count, and the other with a limit.