Re: DataObject idea

From: Date: Tue, 19 Dec 2006 02:16:16 +0000
Subject: Re: DataObject idea
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26154@lists.php.net to get a copy of this message
On 12/18/06, David Sanders <dsanders@baselinesolutions.com.au> wrote:
For example, we have two tables like this: 1) table customer: - int id (primary) - string name - int id_state (not null) 2) table state: - int id - string name with dataobject when we have a $CustomerDO object we can get the relative state, but in "mother" with a "state" dataobject we can retrieve all relative customers (is it called "child data"?). Isn't it powerful? Foreign keys (your id_state) to the state table might appear in many other tables besides customer. To do a reverse lookup you'd need to say which table you want to look up. I think having functions like this would overcomplicate what should be a nice and simple package. Would be nice to see something in DataObjects. $state = 'VIC'; $customer->joinAdd($state); $customer->find();
I agree that this doesn't need to be added explicitly to DB_DataObject as a reverse mapping would require a table to map to and can quite easily be done with just a few lines of code as-is. As for looking up "reverse links" there are a few things you might be interested in for DB_DataObject. DB_DataObject_FormBuilder[1] has a reverseLinks feature which shows all records from a certain table which link to the current table and let you un-link or re-link them to the current record. DB_DataObject_FormBuilder_Frontend[2] has options to show you the links between tables (both ways) and can even show you the records linked to a certain record that you select. See [3] for reverseLinks and the linking tables feature in action. [1] http://pear.php.net/package/DB_DataObject_FormBuilder [2] http://pearified.com/index.php?package=DB_DataObject_FormBuilder_Frontend [3] http://pear.reversefold.com/example/index.php?table=genre&record=1 -- Justin Patrin

« previous php.pear.general (#26154) next »