Yii 1.1: blameable-behavior

See who created/changed a data record

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.



  • Yii 1.0 or above


  • 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:


See the following code example:

public function behaviors()
        return array(
            'Blameable' => array(

If you want to define own column names, just add them in the behaviors method like this:

public function behaviors()
        return array(
            'Blameable' => array(
                '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.

Total 2 comments

#6189 report it
PrplHaz4 at 2011/12/18 01:56am
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....

#180 report it
Orteko at 2010/08/18 02:52am

A related but more involved solution is to log changes to activerecords with the following behavior:


Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: mintao
  • Category: Database
  • Votes: +4
  • Downloaded: 1,295 times
  • Created on: Feb 5, 2010
  • Last updated: Feb 5, 2010