Re: DB_DataObject and Structures_DataGrid integration

From: Date: Wed, 11 Aug 2004 15:20:06 +0000
Subject: Re: DB_DataObject and Structures_DataGrid integration
References: 1 2 3 4 5 6  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-32553@lists.php.net to get a copy of this message
Hi, Andrew Nagy wrote:
Olivier Guilyardi wrote:
    $datagrid->bind($dataobject);
I would need to heavily modify it, because nothing is ready for bind() to support bilateral interactions : it currently reads an array, I need it to read a DataObject but also to instruct it how to sort and limit the data.
Well since I have worked with many of Markus Wolff's ideas when planning and designing the DataGrid, I do like his ideas. The DG, in my mind, is a layer between the interface and the datasource. However, The DG has "drivers" (or whatever you want to call them) for the interface and datasource. I personally would like to see more development in the datasource driver department.
Your point of view is here very helpful to me : if the DG is a such layer between the interface and the datasource, I definitely have to implement what I describe inside the DataGrid package. If, as I first stated, was creating a new package, it would, in this matter, be redundant.
As to the "bind" method, the goal of it is to do what I like to call "Quick and Dirty" action. Someone can simply take a 2D Associative array and call the bind method and then call the render method and have a full DG in only a few lines of code. I would be interested in seeing more options (as Markus suggested) in the bind method; however, I feel that there should be more "drivers" for different datasources.
I understand your first intention when implementing bind(), but I think we really can go further with it. "bind" is the good term, to me. Eventually, there could be a setDataSource() alias for .NET people wondering what's going on with PEAR. Wordnet: bind - v 7: form a chemical bond with; "The hydrogen binds the oxygen" The important point here is that H and O sustain a bilateral interaction.
But I am still confused why Structures_DataGrid_Record_DataObject is not meeting your needs? Why would you want to bind an array of DataObjects when you can do something like the following: $user = new User(); if ($user->find) {
    while ($user->fetch()) {
        $dg->addRecord(new
             Structures_DataGrid_Record_DataObject($user));
    }
}
Please consider reading my previous posts again. My approach is pretty different of DataGrid_Record_DataObject. I do not want bind() to accept an array of dataobjects, but a _single_ dataobject. So what happens when you bind() a dataobject ? 1 - the DataGrid checks if some (query string) input is coming back
    from the user :
- if the user clicked on some the column headers, to sort the data,
    we pass the sort field and direction to DataObject::orderBy()
- if the user is paging through the data, we determine which page
    we're to display, and pass the corresponding information to
    DataObject::limit()
2 - the DataGrid performs a DataObject::find() and _as_many_
    DataObject::fetch() as required
3 - It can now fill multiple records, as well as setup the columns. All of this happened transparently. You just typed "bind".
I do urge you or others to help contribute to Structures_DataGrid!
That's fine for me. What do you think of a DataGrid_Source abstract class as I described in my last answer to Justin ? Then inside a DataGrid/Source directory, DataGrid_Source_DataObject, DataGrid_Source_FooBar, etc... I've no clue if this is a good approach or not. -- og

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