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

#1
[eluser]steelaz[/eluser]
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.

#2
[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.

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

-Lee

#4
[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

SELECT FOUND_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

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

#6
[eluser]steelaz[/eluser]
Thanks Michael, count_all_results() is what I needed. Also in this post there is great example of how it works:

http://ellislab.com/forums/viewthread/73226/#362705


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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