Many-to-many / cascading deletes with DataObject and FormBuilder

From: Date: Mon, 31 Jan 2005 21:50:59 +0000
Subject: Many-to-many / cascading deletes with DataObject and FormBuilder
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17299@lists.php.net to get a copy of this message
I'm using FormBuilder to manage many-to-many relationships and it's working great. It has occured to me that although the inserts and updates to tables in my many-to-many table are handled auto-magically, the deletes on the tables referencing my join table leave orphaned rows in the join table. What's the suggested method for handling deletes of this nature? My initial thought is to override the delete() method in my dataobject class doing something like this (psuedo-code): function delete() { parent::delete(); $joinTable_obj =& DB_DataObject::factory('myJoinTable'); $joinTable_obj->tableAkey = $this->primaryKey; $joinTable_obj->delete(); } Ideally I could tie into the table relationship information in my links.ini file to determine what fields to link together for the delete, but short of that I could just instantiate the related object on my own in the delete() method. Is there a better way to do this? Anyone doing something similar? Thanks. - Jamie

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