On Tue, Jun 30, 2009 at 12:18 AM, Thomas D.<[email protected]> wrote: > Hi, > > I have two tables, drivers and cars. > Each driver in drivers has his cars in cars. > > When I delete a driver, his cars should also be deleted in cars. > > I defined two classes: > > class Drivers extends Zend_Db_Table_Abstract > { > [...] > protected $_dependentTables = array( > 'Cars' > ); > } > > class Cars extends Zend_Db_Table_Abstract > { > [...] > protected $_referenceMap = array( > 'Pages' => array( > 'columns' => array('driver_id'), > 'refTableClass' => 'Drivers', > 'refColumns' => 'id', > 'onDelete' => self::CASCADE > ) > ); > } > > When I run > > $myTable = new Drivers(); > $driversRowset = $myTable ->find(1278); > $driver = $driversRowset->current(); > > $driver->delete(); > > The row with id 1278 in my drivers table will be deleted and also all rows > in cars, where driver_id = 1278. Everything is working as expected. > > Now I want to add a method to my drivers Zend_Db_Table class, which will > delete a driver and do something else: > > class Drivers extends Zend_Db_Table_Abstract > { > [...] > public function doSth($id) > { > $where = $this->_db->quoteInto('id = ?', $id, Zend_Db::INT_TYPE); > $this->delete($where); > > // do my other stuff > [...] > } > } > > My problem is, that when I call $driverTable->doSth(1278), the row in the > driver's table will be deleted, but it won't delete any rows in cars. > > Did I miss something? > > > -- > Regards, > Thomas > > >
Is referential integrity not an option? Andrew
