I have a table (call it Table A) that needs to create multiple additional child records when a Table A record is created. Deleting the Table A record should delete the Table B records.
Deleting the records is easy using ON DELETE CASCADE
in schema.yml
, but adding the records is not all that simple. Overriding Doctrine_Record::postInsert
doesn't do it because the Table A record doesn't have an ID yet. Overriding Doctrine_Form
save doesn't do it, either.
Is an EventListener
the way to go or a database trigger? If the former, do you have an example? If the latter, can the trigger be specified somehow in schema.yml
?