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

From: Date: Mon, 31 Jan 2005 22:33:31 +0000
Subject: Re: Many-to-many / cascading deletes with DataObject and FormBuilder
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17301@lists.php.net to get a copy of this message
if you have access to mysql4 , setup cascade deletes on the foreign keys :) > 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 > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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