Re: Easiest way to add paging to DB resultset?

From: Date: Fri, 18 Nov 2005 11:01:55 +0000
Subject: Re: Easiest way to add paging to DB resultset?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21985@lists.php.net to get a copy of this message
l Burnerheimerton wrote:
You don't have to pass a $pager object, but a $pager_options array: $page = Pager_Wrapper_DB($db, $query, $params);
Please help me know where to go to learn what the array parameters are. The documentation indicates that Pager::Pager() is deprecated and to use factory().
right, normally you'd use the factory() method. When dealing with DB resultsets, though, fetching all the records into an array and then paging the array is inefficient. Thus I wrote a sample wrapper to deal with databases. The Pager::factory() method is called within the wrapper [1], you only have to pass the $pager_options array to it, as you would do to Pager::factory(). i.e. the "$params" parameter you pass to the wrapper: $page = Pager_Wrapper_DB($db, $query, $params); is the same as the "$params" parameter you pass to Pager::factory(). A full list of the array parameters is documented in the manual: http://pear.php.net/manual/en/package.html.pager.factory.php -- Lorenzo Alberton http://pear.php.net/user/quipo [1] i.e. you don't have to call Pager::factory() on your own, the wrapper does it for you: http://cvs.php.net/co.php/pear/Pager/examples/Pager_Wrapper.php

« previous php.pear.general (#21985) next »