total_rows in pagination |
[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.
[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. -Lee
[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
[eluser]Michael Wales[/eluser]
Look into count_all_results() and count_all() within the database class.
[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 |
Welcome Guest, Not a member yet? Register Sign In |