Re: Structures_Datagrid: new DataSource class
| From: | Arnaud Limbourg | Date: | Sun, 01 May 2005 08:21:07 +0000 |
| Subject: | Re: Structures_Datagrid: new DataSource class | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-37462@lists.php.net to get a copy of this message | ||
Hi,
I think the best way to go is to post a feature request on pear bugs.
There is a link on the package homepage.
This way it doesn't ge lost.
Arnaud.
Mark Wiesemann wrote:
> Hi,
>
> I'd like to propose a new DataSource class which can handle DB_Table
> objects.
>
> Here is the code: http://www.markwiesemann.de/php/DB_Table.phps
>
> The code bases on the DB_Result DataSource class. As DB_Table can handle
> sorting in the select* functions the sort function of my class is not
> needed. At the moment a PEAR_Error object is returned if one calls this
> function. I don't know enough of the internals of Datagrid - maybe the
> function is not needed in every DataSource driver class and can be
> deleted.
>
> Usage of the new driver:
>
> (1) Assuming one has a DB_Table object called $c:
>
> require_once 'Structures/DataGrid/DataSource.php';
> $dg =& new Structures_DataGrid();
> $ds = Structures_DataGrid_DataSource::create($c,
> array('view' => 'all'), 'DB_Table');
> $dg->bindDataSource($ds);
> $dg->render();
>
> (2) Assuming the following lines were added in DataSource.php, function
> "_detectSourceType":
> // DB_Table
> case (strtolower(get_parent_class($source)) == 'db_table'):
> return 'DB_Table'; // to be replaced by a new constant
> break;
> you can use it this (common) way:
>
> $dg =& new Structures_DataGrid();
> $dg->bind($c, array('view' => 'all'));
> $dg->render();
>
> In both cases one has to specify a valid key from $c->sql in the option
> array (has to be a name of a predefined select option in DB_Table
> subclass).
>
> My bind function returns two times a PEAR_Error (DB_Result also returns
> one PEAR_Error on failure). Due to a bug (?) in DataGrid this will never
> be displayed or registered. This is because of line 179 of
> DataSource.php (current CVS version):
> $driver->bind($source, $options);
> ==> The returned PEAR_Error get's lost.
>
> It would be nice if the Datagrid team could add this new DataSource
> driver to their package.
>
> Mark
>