Re: paging large amounts of data
| From: | Justin Patrin | Date: | Tue, 23 Aug 2005 16:48:31 +0000 |
| Subject: | Re: paging large amounts of data | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20548@lists.php.net to get a copy of this message | ||
On 8/23/05, Lukas Smith <lsmith@php.net> wrote:
> Justin Patrin wrote:
>
> > No, you don't need to pass in all of the data. See
> > Structures/DataGrid/Renderer/HTMLTable.php for an example of a pager
> > with no data. Basically you just need to pass in 'totalItems'.
>
> ok cool ..
>
> acutally i just discoovered its not that clear immediatly what the
> relevant id's are that i need to fetch. is there an API call that will
> give me the offset that I need to use?
>
> just to make it clear again what I want to do:
>
> // 1 create pager instance
> // 2 pass in all the options
> // 3 fetch total number of items
> // 4 pass in the total number of items and the selected page id
> // 5 get the numbers of the pages that pager needs to generate the link list
> // 6 fetch the id's of these pages
> // 7 pass id's to pager
>
> the trick in the step 6 is that the range is not really fixed. depending
> on the mode things will require a different offset and maybe even limit.
>
Again, I point you to the SDG code. IMHO it does this very well,
passing the limit/offset back from the pager into the data source.
When using SDG with DB_DataObject for instance only the records
required are queried. The only query prior to that is a count(*).
--
Justin Patrin