Yii获取MySql查询执行

时间:2013-07-03 07:48:32

标签: php mysql logging yii

我需要在Save,Update,Delete之前执行MySql查询以创建个人LOG(审计)。

我使用CActiveRecord中的$ model-> save()和$ model-> delete()标准。

我知道怎么做吗?

感谢所有人!

1 个答案:

答案 0 :(得分:2)

您可以使用方法

class Objects extends CActiveRecord

{

 protected function beforeSave()

    {
      // Your code goes here

    }


 protected function beforeDelete()

    {
      // Your code goes here

    }

}

对于查询记录,请参考此帖子Logging

你也可以通过取消注释config.main文件中的以下代码来查看页面上的日志

// uncomment the following to show log messages on web pages

                array(
                    'class'=>'CWebLogRoute',
                ),
相关问题