blameable-behavior See who created/changed a data record

  1. Documentation
  2. Change Log

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 just components, it's on you.
  • Create two extra comlumns for each table you want to track. Default column names are created_by and updated_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.
4 0
9 followers
1 295 downloads
Yii Version: 1.1
License: (not set)
Category: Database
Tags:
Developed by: mintao
Created on: Feb 5, 2010
Last updated: 8 years ago

Downloads

show all