RE: [PEAR] paging large amounts of data

From: Date: Tue, 23 Aug 2005 15:52:28 +0000
Subject: RE: [PEAR] paging large amounts of data
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20541@lists.php.net to get a copy of this message
I'm not sure your questions is about PEAR::Pager but if it's the case, maybe this code could help you ? // Number of news per page $nbNewsPerPage = 10; // Number of news $nbNews=$DBNews->getNbNews (); $params = array( 'mode' => 'Sliding', // "Jumping" or "Sliding" -window - It determines pager behaviour. 'perPage' => $nbNewsPerPage, // Number of items to display on each page 'delta' => 5, // Number of page numbers to display before and after the current one 'totalItems' => $nbNews // Array of items to page ); $pager = & Pager::factory($params); $links = $pager->getLinks(); // Get only the news I want (between nbNewsPerPage and $pager->getCurrentPageID()-1)*$nbNewsPerPage) : $news = $DBNews->getNews ( $nbNewsPerPage, ($pager->getCurrentPageID()-1)*$nbNewsPerPage ); -----Message d'origine----- De : Klaus Guenther [mailto:klaus@capitalfocus.org] Envoyé : mardi 23 août 2005 17:38 À : Lukas Smith Cc : pear-general@lists.php.net; Lorenzo Alberton Objet : Re: [PEAR] paging large amounts of data On 8/23/2005 5:26 PM, Lukas Smith spake the following words: > Hi, > > its not entirely clear to me how paging of large amounts of data are > going to work. essentially the way things seem to me is that I need to > stick in an array with all the id's of the entire dataset, even if in > the end I am only interested in a small number of all the id's and even > if I am able to specifically extract these ids using LIMIT (or some > equivalent syntax) from the database. > > Is there a way to just pass in a count of the total number of items in > the dataset instead? It does not seem sensible to fake this huge array > either. Off the top of my head... What you do is pass an array of the total number of items, storing merely an ID for each one. When you generate the page, just grab the items you want from the database. Does that sound reasonable? Klaus -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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