![]() |
How does the pagination class work? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: How does the pagination class work? (/showthread.php?tid=44101) |
How does the pagination class work? - El Forum - 08-03-2011 [eluser]zxcv[/eluser] Hello! I'm wondering how the pagination class works. My code is similiar to this: CONTROLLER Code: class Books extends Controller { MODEL Code: class books_model extends Model { The view just makes the table and the pagination links. I am wondering how "the flow of the pagination" is going here? Does a click on an pagination link call a new mysql query? How does the pagination class work? - El Forum - 08-03-2011 [eluser]appleboy[/eluser] Hi, Please paste your books_view views source code. How does the pagination class work? - El Forum - 08-03-2011 [eluser]waynhall[/eluser] It sends a value (the offset) to the function at the url specified in config. (Which is the same as uri segment 3) controller/function/$offset You can access its value by placing a parameter on your index() function: Code: function index($offset) { In your case, as you click next, you'll go to: /books/index/5 // $this->index(5) /books/index/10 // $this->index(10) /books/index/15 // $this->index(15) ... and so on. Its zero based, so going to the url books/ is the same as /books/index/0 I usually create a separate function (not index) that handles the pagination: Code: public function index() |