This extension logs with every created or updated row in your database who created and who updated it. This may interest you when working in a group of more people sharing same privileges.
So you can see who changed what record set and - in combination with the timestampable behavior - when.
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
components/behaviors
or justcomponents
, it's on you. - Create two extra comlumns for each table you want to track. Default column names are
created_by
andupdated_by
. Column type should be varchar(128) - Add this behavior to your desired model:
Usage ¶
See the following code example:
public function behaviors()
{
return array(
'Blameable' => array(
'class'=>'application.components.behaviors.BlameableBehavior',
),
);
}
If you want to define own column names, just add them in the behaviors method like this:
public function behaviors()
{
return array(
'Blameable' => array(
'class'=>'application.components.behaviors.BlameableBehavior',
'createdByColumn' => 'my_own_creator_column_name',
'updatedByColumn' => 'my_own_updater_column_name',
),
);
}
PLEASE MENTION to change the class
attribute to where you located this little behavior. So the above examples only work, if you created an extra behaviors folder in your components directory (as I did).
Change Log ¶
February 5, 2010 ¶
- Initial release.
ActiveRecordLogableBehavior
A related but more involved solution is to log changes to activerecords with the following behavior:
http://www.yiiframework.com/doc/cookbook/9/
Maybe include dates with this as well?
For most of my models that use a similar behavior, it's beneficial to also include dates/timestamps that go with createdby and updatedby...this is pretty much standard issue for most of my records....
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.