How to log changes of ActiveRecords?

Comparing #3 with #4

Revision #4 was created by pfth pfth on Feb 13, 2009, 12:40:14 PM.

Added PHP code format

Content

[...]
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
[...]