Revision #6 has been created by jonah on Feb 13, 2009, 7:29:44 PM with the memo:
Fixed spelling errors and improved sentence readability
« previous (#5) next (#7) »
Changes
Title
unchanged
How to log changes of ActiveRecords?
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
Content
changed
If you want to knowA simple and effective way to keep track what
theyour users are doing within your application
, you need is to log the
ir activities rel
eated to database modifications.
Normally you would like to knowYou can log whenever a record was inserted, changed or deleted
, and also when and by which user this was done. For a [CActiveRecord] Model you could use a behavior for this purpose.
SoThis way you will be able to add log functionality to ActiveRecords very easily.
First of all you have to create a table for the log
-lines in the database. Here is an example (MySQL):
CREATE TABLE ActiveRecordLog (
idActiveRecordLog INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
description VARCHAR(255) NULL,
action VARCHAR(20) NULL,[...]