DB_DataObject Inserting into linked tables
| From: | Jacob Singh | Date: | Thu, 15 Apr 2004 11:47:40 +0000 |
| Subject: | DB_DataObject Inserting into linked tables | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-11856@lists.php.net to get a copy of this message | ||
I have a major bummer now, I’ve developed a bunch of admin pages without
handling the insert side of things, and now I’ve realized it’s maybe not
possible this way and I have to rebuild. Say I’m working with artists,
right?
So I have a form that contains fields from both person and employee fields
say. Employee uses the same ID for a primary key as it’s ID in the person
table. So I need to make an insert into person and then get the new ID and
make an insert into employee. The problem is, I can’t do getLinks() unless
there is and ID available to link on. But the rest of my script uses
getlinks() extensively, so I am setting all the fields for the insert at the
same time I set them for the update with
$employee->_person_id->setFrom($person_fields); and
$employee->setFrom($employeeFields). Them I just run update on each object.
Now what can I do? I can’t use setFrom() on $employee->_person_id because
it doesn’t exist because I wasn’t able to link it (because there is no ID
yet). Any ideas?
thanks
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