Answer the question
In order to leave comments, you need to log in
Why is beforeDelete() not called when deleting via Something::model()->deleteByPk(...)?
I am using Yii version 1.
I'll give you an example. There is an Article model. Inside its beforeDelete() , I delete another entity with Category::model()->deleteByPk(...). Inside the Category, in its beforeDelete() , I similarly delete another other entity.
The fact is that there is a way to delete via Category::model->deleteByPk(...), the internal beforeDelete is no longer called.
That is, if you delete in an Article Category using deleteByPk(...), then inside the Category beforeDelete() is not called. Whatever comes up, needs to be done
$category = Category::model()->findByPk($this->route_id);
if ($category)
{
$category->delete();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question