Overriding delete() method in bespoke AR


I am overriding the standard AR delete method so that instead of using deleteByPk() it will use a new function:

public function retireByPk($pk,$condition='',$params=array())






       return $command->execute();


Every table in the DB has a column called state. When something is ‘deleted’ its state changes to 2. Thats what the retireByPk function will achieve.

I need to create a new method createRetireCommand in an extension of CDbCommandBuilder however am not sure how to extend this class - what new files do I need & where in my project do I have to reference it?




Just today I read about a soft delete in Yii cookbook. The way it was done is by using behavior which has some methods that update the delete state.

Hi there,

ok sure sounds good.