Re: Structures_DataGrid Data Sources
| From: | Olivier Guilyardi | Date: | Fri, 20 Aug 2004 01:03:08 +0000 |
| Subject: | Re: Structures_DataGrid Data Sources | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-32773@lists.php.net to get a copy of this message | ||
Hi,
Andrew Nagy wrote:
Many of you may have noticed the fairly long thread about Integrating DB_DataObject with Structures_DataGrid. Olivier Guilyardi and I (mainly Olivier) have put together an Abstract Data Source Driver class as well as 4 Data Source Driver classes. As I am focusing the next release for SDG on beta, I hope that all who are interested would take a look at the code in CVS and leave some feedback. I think that Olivier would like to see this concept progress into a new Package for combining any datasource to any type of "renderer" other than just DataGrid.Some additional information : Tests and documentation : http://xung.org/misc/dgdo/sdg_source/test/index.html Our goal is : $datagrid->bind($source); Where source can be : a dataobject, an associative array, an xml string, a db result, or an rss document (more to come). The bind method is smart, it will detect the kind of data you pass to it. Like : $datagrid->bind($dataobject); or $datagrid->bind($xml); As discussed in the original "DG/DO integration" thread, the bind() method will establish a two-way connection with the source. All of that's achieved by a new layer : the Structures_DataGrid_DataSource* classes. The create() method is a factory to load a datasource driver. This is where the real work gets done, detection, driver instantiation and the like. The DataSource layers features drivers which are classes that extend the base Structures_DataGrid_DataSource abstract class, like : Structures_DataGrid_DataSource_XML, Structures_DataGrid_DataSource_DataObject, etc... All of this new layer is tested and works with php4 and php5, as you can see by pointing your browser to the link I provide above. (except the RSS driver, not tested yet). In the Structures_DataGrid_DataSource class phpdoc documentation, you can also read about how to create a new driver. There's a howto in the class description. The documentation is still pretty incomplete, though. Comments are very welcome. Andrew and I have been discussing a lot on the design and implementation. Some of the questions : - if we are to raise errors from constructors, is PEAR::raiseError() sufficient ? I personally consider that it is not, because it outputs nothing on a default setup. - is the switch construct in Structures_DataGrid_DataSource::_detectSourceType() acceptable ? I personally think it's not. It's like using a screwdriver as hammer. But it works. - taking in account this new layer, how do you envisage datagrid/forms integration ? (Justin, this one's for you ;-) - what do you think of the XPath feature of the XML driver ? -- og