Problem is that i can’t think how to get old data from deleted row if its possible
In model file
protected function afterDelete() {
Yii::log('caption = '.$this->caption, 'info', 'dummy afterDelete'); // this i see in my log file. so i know it gets there <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />
}
the same code on afterSave work fine, ofcourse (look below)
I’m not sure, but i think there was an behavior extension for this. Basic principle: Store the original attribute values inside a custom [b]afterFind/b method (e.g. in another property private $_oldValues;). Then you can access the old values from this property in [b]afterSave/b.
private $_oldValues = array();
public function afterFind()
{
parent::afterFind();
$this->_oldValues = $this->attributes;
}
public function afterDelete()
{
parent::afterDelete();
$this->_oldValues['caption']; //field value you want to access
}
If you use a delete call that affects multiple records (like Some::model()->deleteAll(‘id < 5’) ) afterDelete() will not be called for these records! This is by design because this command issues a DELETE SQL statement to the DB without reading in all the records before. You should be aware of this minor limitation of afterDelete().