total_rows in pagination - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: total_rows in pagination (/showthread.php?tid=6485) |
total_rows in pagination - El Forum - 02-29-2008 [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. total_rows in pagination - El Forum - 02-29-2008 [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. total_rows in pagination - El Forum - 02-29-2008 [eluser]CI Lee[/eluser] Post the code you have for your pagination config and I will see if I can help you out. -Lee total_rows in pagination - El Forum - 02-29-2008 [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 total_rows in pagination - El Forum - 02-29-2008 [eluser]Michael Wales[/eluser] Look into count_all_results() and count_all() within the database class. total_rows in pagination - El Forum - 03-04-2008 [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 |