-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You should probably take a look at Foreign Keys and Cascading in your
database's manual.
...................................
: ___ _ ___ ___ ___ _ ___ :
: | \ /_\ / __| _ \ _ (_) \ :
: | |) / _ \\__ \ _/ / | |) | :
: |___/_/:\_\___/_| |_|_\_|___/ :
:........:........................:
: Web : http://www.dasprids.de :
: E-mail : [email protected] :
: Jabber : [email protected] :
: ICQ : 105677955 :
:........:........................:
Thomas D. schrieb:
> 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?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkpKI5cACgkQ0HfT5Ws789B2ogCgiElFfBypyBWKPD3l5v4dqa1k
wkkAoIe7o8TUAhNCBFXRdgrV1T4ZUmUN
=mSbg
-----END PGP SIGNATURE-----