• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
total_rows in pagination

Is there a smart way to pass $config['total_rows'] to pagination lib?

My search queries are complex and I have to run them twice. One to get total number of rows without $this->db->limit(), and the other with $this->db->limit() to get current page results.

[eluser]Noah David[/eluser]
If you figure it out, let me know. We're running two queries here too to get current results vs. all results.

[eluser]CI Lee[/eluser]
Post the code you have for your pagination config and I will see if I can help you out.


[eluser]Matthew Lanham[/eluser]
Im not sure you can do this through the active record part of the database class, but MYSQL has a build in way of doing this, for example:

SELECT * from tblEmployees limit 10

would be changed to

SELECT SQL_CALC_FOUND_ROWS * from tblEmployees limit 10

Then to get the total rows


by adding SQL_CALC_FOUND_ROWS to any query with a limit it basically allows you to get the total rows found by using FOUND_ROWS()

You may be able to use:

$this->db->select('SQL_CALC_FOUND_ROWS *');

Hope this helps

[eluser]Michael Wales[/eluser]
Look into count_all_results() and count_all() within the database class.

Thanks Michael, count_all_results() is what I needed. Also in this post there is great example of how it works:


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.