I have table with column id, name and parentid
relation function in model:
\'location_parent\' => array(self::BELONGS_TO, \'Location\', \'parenti
In your model override the beforeDelete
method to delete all child records recursively before deleting the parent i.e.
public function beforeDelete(){
foreach($this->location_children as $c)
$c->delete();
return parent::beforeDelete();
}
Be sure to wrap the initial delete call in a transaction to ensure all or none of the records are deleted.
You could also just use CDbCommand
to perform the deletion.