Re: Re: Datagrid and DataObject and performance

From: Date: Tue, 14 Dec 2004 17:03:20 +0000
Subject: Re: Re: Datagrid and DataObject and performance
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16229@lists.php.net to get a copy of this message
cron@odi.com.br wrote:
Your problem is calling the find method before the bind. Do not do this as DataGrid will call the find for you so that you can do sorting and paging.
While it is good not have to call the bind method in some situations in others is very bad. I often limit the result of the query based on the page and pass the count to totalItens of the pager so only the necessary data is taken from the database is passed to datagrid the drawback is have to do select count every time but still is better them have to select all the data every time.
If you don't want to use the automatic paging and sorting, then don't use the bind or bindDataSource method for your dataobject. You can also loop through your results and add it to the datagrid, or create and array and bind it, for example: while ($do->fetch()) {
    $dg->addRecord(new Structures_DataGrid_Record($do->toArray()));
} OR while ($do->fetch()) {
    $recordSet[] = $do->toArray();
} $dg->bind($recordSet); This will allow you to have full controll over the fetching process. Andrew

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