call afterDelete by another afterDelete

Hi, is able to call afterDelete by another afterDelete?

i have category, items and its values.

when i delete category, i want to delete all items in specified category and then i want to delete values related to specified item.

so category model:




afterDelete() {

     item::model()->deleteAll('category_id = '.$this->category_id);

}



item model:




afterDelete() {

     value::model()->deleteAll('item_id = '.$this->item_id);

}



thx

Since deleteAll() method deletes all models by one query, afterDelete() method won’t be called.

If you want afterDelete() method to be called, then retrieve all items by category_id and call delete() method in a loop.

One more (good) way is to use mysql possibility to automatically delete all related records by setting foreign keys and "ON DELETE CASCADE".

thank you.

i think that i’m doing something wrong …