How to delete refClass record in Doctrine?

Posted by terrani on Stack Overflow See other posts from Stack Overflow or by terrani
Published on 2010-04-07T06:18:06Z Indexed on 2010/04/07 6:23 UTC
Read the original article Hit count: 257

Hi all!

I have many-to-many relations with the following tables.

post tag post_tag

I created three classes with Doctrine, so I have the following classes as well.

BasePost BaseTag BasePostTag

in the setUp() method, I defined relations. I like to delete tag record when I delete post record. So I simply put cascade as descirbed on Doctrine document.

$this->hasMany("Tag as Tags",array(
    'refClass' => 'PostTag',
    'local'=>'object_id',
    'foreign'=>'tag_id',
    'cascade'=> array('delete')
));

it works without a problem.

My questions is, how do I delete a record from post_tag table? Do I need to create a query myself?

© Stack Overflow or respective owner

Related posts about doctrine

Related posts about delete-relation