Re: DB_DataObject and Structures_DataGrid integration

From: Date: Fri, 13 Aug 2004 23:09:03 +0000
Subject: Re: DB_DataObject and Structures_DataGrid integration
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-32659@lists.php.net to get a copy of this message
Justin Patrin wrote:
$dg->bindDataSource('dataObject', $do);
Why passing a such additionnal 'dataObject' parameter ? is_subclass_of() is everything we need. Some other sources can be parsable strings.
The 'dataObject' is an identifier for the backend. Yes, it can be done through is_subclass_of, but others expressed that if you add lots of data sources, you have a huge if/else in bind(). You also have to change it every time you add a new data source. Think of this like DB::connect() which forces you to specify your DB type. Then it auto-loads and instatiated the backend you need. IMHO, DG should use somehting similar so as not to create an adminstration nightmare in bind() and to save extra processing time in bind().
I see, you'd do something like : function bind($type,$data) { require_once "Structures/DataGrid/Source/$type.php"; $classname = "Structures_DataGrid_Source_$type"; $this->source =& new $classname($data); } It's just... I found the following stylish : $datagrid->bind($dataobject); But your (or DB's) method is the lightest, for sure. I'll see if I can find some nice way to retain the above syntax. -- og

« previous php.pear.dev (#32659) next »