Re: Datagrid and DataObject and performance

From: Date: Mon, 13 Dec 2004 20:20:54 +0000
Subject: Re: Datagrid and DataObject and performance
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16204@lists.php.net to get a copy of this message
I don't really need it, just playing around with some personal projects in the free time. Reading the docs just thought databject layer was ready and for now I will transform the dataobject into array pass to datagrid. When it comes out I will make the necessary changes. But if you fell like testing datagrid+dataobject I will be happy to do it. Angelo ----- Original Message ----- From: "Olivier Guilyardi" <ml@xung.org> To: <cron@odi.com.br> Cc: <pear-general@lists.php.net> Sent: Monday, December 13, 2004 3:18 PM Subject: Re: [PEAR] Datagrid and DataObject and performance
cron@odi.com.br wrote:
Hello Again, After look at the examples just find to be allot easier to just bind the data and let DataGrid do the work however I have this code and it does not work: $obj_db = DB_DataObject::factory('acesso'); $obj_db->find(); $dg = new Structures_DataGrid(4); $dg->bind($obj_db); $dg->render(); But if I transform the DataObject to array it works fine. $obj_db = DB_DataObject::factory('acesso'); $obj_db->find(); while ($obj_db->fetch()) { $arr[] = $obj_db->toArray(); } $dg = new Structures_DataGrid(4); $dg->bind($arr); $dg->render(); Would be nice to direct bind the DataObject to the data grid but I have no problem transforming DataObject into array but one question remains : Is this a great performance hit?
Transforming the dataobject to an array will be much slower if your database table is big. The Datagrid's dataobject driver is clever enough to fetch only the few rows it needs to display. But, if you let the datagrid handle paging and sorting, but pass it an array, you need the dataobject to fetch the entire table, which will be funny if you have, say 1000000 of rows :-) But there is a problem : The datagrid+databject coupling does not work yet. Actually I'm the one who wrote the datasource layer (interaction with dataobjects, xml, etc...) and I do have a fully working version of the Datagrid, which will page and sort your dataobject with a simple "$dg->bind($obj_db);". If you really need this ASAP I can put it online. However, Andrew Nagy (Datagrid's lead maintainer) is in the process of (soon) releasing a brand new release which should fix all this. -- og -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


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