RE: [PEAR] Re: DB_DataObject: Updating Linked Tables Best Pactices

From: Date: Tue, 06 Apr 2004 10:00:53 +0000
Subject: RE: [PEAR] Re: DB_DataObject: Updating Linked Tables Best Pactices
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11645@lists.php.net to get a copy of this message
Yeah, that's what I'm doing now... Seems to work okay. Another quick question. I'm using setFrom($fields) to fill the objects. Basically I prefix the field names that go to employee with employee_ and the ones that go to person with person_. I have a little function (fill_fields) to parse out the table names and send the correct fields to the correct object. Then I run $employee->_person_id->setFrom($personFields), and the same for employee. Person has a field called history_file which contains a word doc. So the form has an upload field. So I hack the fill_field() thing to give the name of the file field instead of the actual value (which is an array) to the $employee->_person_id->sethistory_file($v) function. This would work fine except that you put the file in a different directory and give it a different name if it is an employee or a client. Since you're calling setFrom() on the $employee->_person_id object, it can't know that it's part of $employee right? If so, I could get the options from a method in the $employee object, but I don't think I can do this. So do I put the sethistory_file($v) method in employee? Could this find the actual sethistory_file($v) method in Person? Sounds like hackapalooza to me. :) Uggh... Jacob Singh Technical Director Calabashmusic.com -----Original Message----- From: Alan Knowles [mailto:alan@akbkhome.com] Sent: Tuesday, April 06, 2004 6:22 AM To: pear-general@lists.php.net; Jacob Singh Cc: pear-general@lists.php.net Subject: [PEAR] Re: DB_DataObject: Updating Linked Tables Best Pactices I'd be tempted to overload the update() method in the child class, to do an if (isset($this->_person)) .. $this->_person->update(); or, explicity have a method which updates the linked records.. (which may be clearer in the code..) Regards Alan Jacob Singh wrote: > The docs don't mention it, but what if you want to update linked records? I > can't seem to get it to work... This would be handy for joins that are > basically sibling in nature, i.e. > > > > so if I have $person and $employee > > > > and I run: > > > > $employee->rank = 5; > > $employee->_person_id->name = "foo"; > > > > $employee->update(); > > > > This only updates the rank not the name. If you have a form with both fields > on it, what are best practices for this? > > > > thanks, > > Jacob > > > > Jacob Singh > > Technical Director > > Calabashmusic.com > > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.617 / Virus Database: 396 - Release Date: 3/9/2004 > > -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.617 / Virus Database: 396 - Release Date: 3/9/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.617 / Virus Database: 396 - Release Date: 3/9/2004

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