Welcome Guest, Not a member yet? Register   Sign In
count_all_results() not returning correct result
#10

[eluser]alphastudio[/eluser]
I found my own solution.

Something like this does the trick:

Code:
$this->db->select( 'SQL_CALC_FOUND_ROWS, `table1`.`id`, `table2`.`something`', false );
$this->db->from( 'table1' );
$this->db->join('table2', 'table1.id = table2.id' );
$this->db->group_by( 'table2.something' );
$this->db->limit( 25, 0 );
$result = $this->db->get();

$total_results = $this->db->query( 'SELECT FOUND_ROWS() total' )->row()->total;

As a reminder, the purpose of this is retrieving a certain amount of rows to display in a paginated list, while also getting the total amount of rows. For instance, I might be displaying the 25 first rows out of 150 total rows (which would be $total_results).

I hope this helps someone else, I'm not very good at this sample code thing...


Messages In This Thread
count_all_results() not returning correct result - by El Forum - 01-31-2009, 06:25 PM
count_all_results() not returning correct result - by El Forum - 01-31-2009, 07:25 PM
count_all_results() not returning correct result - by El Forum - 01-31-2009, 07:50 PM
count_all_results() not returning correct result - by El Forum - 02-01-2009, 06:07 AM
count_all_results() not returning correct result - by El Forum - 02-01-2009, 06:54 AM
count_all_results() not returning correct result - by El Forum - 02-01-2009, 06:56 AM
count_all_results() not returning correct result - by El Forum - 02-01-2009, 09:54 PM
count_all_results() not returning correct result - by El Forum - 02-01-2009, 10:27 PM
count_all_results() not returning correct result - by El Forum - 10-07-2013, 05:18 AM
count_all_results() not returning correct result - by El Forum - 10-07-2013, 05:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB