Pagination using two functions, is it possible just to get it down to one? - 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: Pagination using two functions, is it possible just to get it down to one? (/showthread.php?tid=36211) |
Pagination using two functions, is it possible just to get it down to one? - El Forum - 11-25-2010 [eluser]Otemu[/eluser] Hi, I have two calls to the model class for my pagination to work, but I was wondering if I could get this down to just one function. The first function queries the database and returns the number of rows Code: function getNewsAllN() { and the second function queries the database and returns the rows. Code: function getNewsAll($num, $offset) { Code: $numrows = $this->M_Articles->getNewsAllN(); is it possible some how to narrow this just to one function call? Pagination using two functions, is it possible just to get it down to one? - El Forum - 11-25-2010 [eluser]Jareish[/eluser] Your $data['records'] is an array. And like any array in php, you can count the number of objects in it using count(); Think $numrows = count($data['records']); should do it Pagination using two functions, is it possible just to get it down to one? - El Forum - 11-25-2010 [eluser]n0xie[/eluser] [quote author="Jareish" date="1290711958"]Your $data['records'] is an array. And like any array in php, you can count the number of objects in it using count(); Think $numrows = count($data['records']); should do it[/quote] No. that would just count your 'per_page' number. You can't do it without using 2 queries afaik. Pagination using two functions, is it possible just to get it down to one? - El Forum - 11-25-2010 [eluser]Otemu[/eluser] Thanks for the reponse's guys, that helps a lot |