Revision #4 has been created by pfth on Feb 13, 2009, 12:40:14 PM with the memo:
Added PHP code format
« previous (#3) next (#5) »
Changes
Title
unchanged
How to log changes of ActiveRecords?
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
Content
changed
[...]
The behavior class uses the ActiveRecordLog Model to store the log lines into the database. It will log a line each time a record is inserted or deleted. It will also log a line for each field which is changed.
In order to make an ActiveRecord Model use this behavior, you have to add the following code to the Model class:
```php
public function behaviors()
{
return array([...]
);
}
```
Of course this simple example could be enhanced:
+ support for mult-column primary keys
+ savethe attributeLabels instead of the field names[...]