Re: DB_DataObject and Structures_DataGrid integration
| From: | Markus Wolff | Date: | Tue, 10 Aug 2004 15:20:11 +0000 |
| Subject: | Re: DB_DataObject and Structures_DataGrid integration | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-32533@lists.php.net to get a copy of this message | ||
Olivier Guilyardi wrote:
Structures_DataGrid is .NET'ish. And browsing the related .NET documentation, I can see there are many data providers, but it always end up with a : datagrid->datasource = someDataProvider. According to this, you definitely are right about adding a driver to DataGrid. Do you think I can do this by creating a new package ? Or should I modify DataGrid ?How about this: Just pass the datasource object (or array or resource or whatever) to a factory method, which looks at the type of the datasource (using get_class, is_array etc.) and then returns an instance of the appropriate DataGrid class, like Structures_DataGrid_DataObject, Structures_DataGrid_Array etc. It's pretty easy to do and very effective. If you can't use a factory method, make a setDatasource() method which also does type checking and then makes an instance of a suitable adaptor class that the DataGrid can use as a general interface to datasources. The real datasource will be passed to the adaptor class and the adaptor object will be used as the datasource. CU Markus