Home > Archive > PHP Pear > June 2006 > Re: [PEAR] Structures_DataGrid
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] Structures_DataGrid
|
|
| Olivier Guilyardi 2006-06-28, 8:01 am |
| Hi Markus,
Markus Ernst wrote:
> I try to use Structures_DataGrid for importing Data of various formats.
> So, after successfully bind()ed the data I would like to get them out as
> an array with the same structure as used for filling the Array
> datasource driver.
>
> As I did not find some kind of getRecordSet() method in DataGrid, I
> wonder what would be the appropriate way to get the data out:
Please post a feature request. I think we can safely add a getRecordSet() method
or create an array renderer. You're not the first to ask that sort of feature,
if I remember correctly.
> 1. Write a new class which inherits Structures_DataGrid and provides a
> public method to retrieve the recordsets
No, the $recordSet property is private, not protected.
> 2. Write a new renderer that returns the data as an array
You can do that, yes : subclass SDG_Renderer, "merge" $_columns and $_records in
buildBody(), and return the resulting array with getOutput().
Shouldn't be much more than 10 lines.
> 3. Dirty way: $data = $datagrid->recordSet;
No, _all_ properties in SDG are private or protected.
--
og
| |
| Olivier Guilyardi 2006-06-28, 6:59 pm |
| Markus,
Olivier Guilyardi wrote:
> Markus Ernst wrote:
>
>
> Please post a feature request. I think we can safely add a
> getRecordSet() method or create an array renderer. You're not the first
> to ask that sort of feature, if I remember correctly.
>
>
> You can do that, yes : subclass SDG_Renderer, "merge" $_columns and
> $_records in buildBody(), and return the resulting array with getOutput().
> Shouldn't be much more than 10 lines.
Actually, there's a much better way, just use the DataSource directly.
For example with XML :
$datasource = new Structures_DataGrid_DataSource_XML();
$datasource->bind($xml);
$data = $datasource->fetch();
DataGrid's DataSource layer provide a common interface for retrieving tabular
data from all sort of formats/backends/etc... And you can use DataSource::sort()
and DataSource::count() with all of them.
In this regard, I think it's similar to SDO : http://pecl.php.net/package/sdo
(although I never tried it)
--
og
| |
| Markus Ernst 2006-06-28, 6:59 pm |
| Olivier Guilyardi schrieb:
> Actually, there's a much better way, just use the DataSource directly.
>
> For example with XML :
> $datasource = new Structures_DataGrid_DataSource_XML();
> $datasource->bind($xml);
> $data = $datasource->fetch();
>
> DataGrid's DataSource layer provide a common interface for retrieving
> tabular data from all sort of formats/backends/etc... And you can use
> DataSource::sort() and DataSource::count() with all of them.
That's good! Anyway for compatibility with the automatic datatype
detection functionality a DataGrid::getDataSource() method (according to
getRenderer()) seems necessary to me; I posted a feature request for this.
--
Markus
|
|
|
|
|