CodeIgniter Forums
How to limit the resultset when using 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: How to limit the resultset when using pagination? (/showthread.php?tid=22463)



How to limit the resultset when using pagination? - El Forum - 09-10-2009

[eluser]kbkb[/eluser]
Hi i want to use pagination. I read the userguide http://ellislab.com/codeigniter/user-guide/libraries/pagination.html here.
But i dont know how to limit the resultset. Is there some kind of command which i should pass to the database-class that the right part of the resultset is display? It always display me the whole 100s of entries and don't show any pagination-links.


greetings


How to limit the resultset when using pagination? - El Forum - 09-10-2009

[eluser]Dam1an[/eluser]
You would need to use a limit clause in your model which would define how many to retreive at once and the offset
The offset is the last URI segment and the limit is how many you want per page


How to limit the resultset when using pagination? - El Forum - 09-10-2009

[eluser]Thorpe Obazee[/eluser]
You can probably look at this: Pagination with CodeIgniter

It actually works just like pagination classes on the web but easier since the offset is often seen on the URL.


How to limit the resultset when using pagination? - El Forum - 09-10-2009

[eluser]jegbagus[/eluser]
kbkb, add LIMIT query at your sql.
example :
Code:
select * from yourtable limit 10,5
10 will be the number generated by CI pagination library, and 5 number of row every page.

best regard


How to limit the resultset when using pagination? - El Forum - 09-10-2009

[eluser]kbkb[/eluser]
Thank you guys.

I had think, that the pagination-class instantly take access to the db-class and limit the result set there. Don't know, that i have made something by hand Smile But its a really nice solution, very copy-and-pastable Big Grin