the code i pasted is from the CActiveRecord.php file . ok.. not my code.

Sorry, but how were we supposed to know that it's yii code ?

Rajith R, on 18 April 2013 - 05:57 AM, said:

i am saying that the deleteAllByAttributes(); deleteAll(); deleteByPk(); are not going through the beforeDelete().

very simple.

Override yii deleteAll() with your own in your model :

public function deleteAll($condition='',$params=array())
{
// find all records using the $condition ans $param
// loop on this records, one by one to trigger ->delete()
// return true if all deletion were successfull
}

It's in fact a limitation, but I think it's a reasonable design decision.

It's true that "deleteAll" could be implemented so that "beforeDelete" would be called for every deleted record. But I don't want it.

When I want to use "deleteAll", what I really want is a thin wrapper over the plain sql of "DELETE FROM ... WHERE ...". I don't want Yii to read all the target records into AR objects before deleting them. It would significantly slow down the process.

It's in fact a limitation, but I think it's a reasonable design decision.

It's true that "deleteAll" could be implemented so that "beforeDelete" would be called for every deleted record. But I don't want it.

When I want to use "deleteAll", what I really want is a thin wrapper over the plain sql of "DELETE FROM ... WHERE ...". I don't want Yii to read all the target records into AR objects before deleting them. It would significantly slow down the process.

Yeah.. i also found that it would slow down the process ,because of read to AR.