Doctrine 1.2 delete object and all relationships


Doctrine provides the ability to easily delete a doctrine record object and all it’s relationships. If you populate the entire doctrine object when it’s instantiated, just call the delete() method and it will delete everything. If you use lazy loading, you’ll need to call the delete method on each relationship –

$objRecord = Doctrine_Core::getTable('Table')->find(1);
$objRecord->RelationshipOne->delete();
$objRecord->RelationshipTwo->delete();
$objRecord->delete();

Leave a comment

Your email address will not be published. Required fields are marked *