Problems with BeforeDelete and deleteAllFromAttributes

Hi, im doing a system that needs to delete some related records that is not join using a relation, then i made some changes in my model, and add the event "BeforeDelete" for test when a user deletes some data from this table, and the model deletes all related records of this one, but when i try to use deleteAllFromAttributes that method doesnt start.

How should i use the event for catch the deletion using that method?

Thanks for your help (and sorry about my bad english)

code please

But just as a starter: I think you should have set up relations for related data

This is by design. When you call any deleteAll() method, the records are not loaded into memory. Instead a DROP FROM TABLE … SQL command is sent to the DB. Thus there’s no object created for the deleted records and hence the beforeDelete() is not called in this situation.

1 Like

use this





Modelname::model()->deleteAllByAttributes(array('uid'=>'','mid'=>''));




Thanks for your answers, like mike says its true, i cant follow a deleteAll with BeforeDelete because the records are not in memory or object, and i cant follow that event, i must delete one by one using the delete command, thanks again for your answer

okay.