Re: Limited db paging with datagrid

From: Date: Tue, 04 Jan 2005 22:14:14 +0000
Subject: Re: Limited db paging with datagrid
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16602@lists.php.net to get a copy of this message
Electroteque wrote:
Would anyone have an example of how to implement the limited db paging using Pager with datagrid ? It looks like it pages the array which means you have to extract the entire resultset first which is slow. Let me know.
If you want to have paging, and you are not using DB_DataObjects you must load all of the data upfront. You could create your own instance of the pager class, but it works the same way by counting the array of data. The only thing that I can think of is to try this hack, but don't hold me to it because I haven't tried it: $result = $db->query("SELECT COUNT(*) AS count FROM users"); $record = $result->fetchRow(); $result = $db->query("SELECT * FROM users LIMIT 20"); $dg->bind($result); $dg->pager->_totalItems = $record['count']; And if you don't like any of these ideas, just create your own paging based on a count query. Hope this helps and let me know what your solution is Andrew

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