Page 1 of 1

automatism to delete related records

PostPosted: Sun Feb 10, 2008 5:24 am
by kurisusan
Hello,

is there any automatism to delete related records after having deleted a 'parent' record?

Christian

PostPosted: Sun Feb 10, 2008 9:23 am
by shannah
Best way is to use the INNODB storage engine for those tables, and then use a foreign key relationship with "on delete cascade".

That way the database will always stay consistent.

The alternative is to use an afterDelete() trigger in the parent record to delete the child.

PostPosted: Sun Feb 10, 2008 10:31 am
by kurisusan
Thanks. I cannot change the db enginge, though.
As Record->delete() is not implemented, how do I delete a record? Using plain sql?

Christian

PostPosted: Sun Feb 10, 2008 6:03 pm
by shannah
Yes. Best just to do mysql_query()