Yii Get MySql query executed

泄露秘密 提交于 2019-12-24 19:09:18

问题


I need get the MySql query executed before Save, Update, Delete for create a personal LOG (audit).

I use $model->save() and $model->delete() standard from CActiveRecord.

Any know how i can do this?

Thanks to all!


回答1:


You can use the methods

class Objects extends CActiveRecord

{

 protected function beforeSave()

    {
      // Your code goes here

    }


 protected function beforeDelete()

    {
      // Your code goes here

    }

}

For Logging of query you refer this thread Logging

u can also see the log on the page by just uncommenting the follwing code in config.main file

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

                array(
                    'class'=>'CWebLogRoute',
                ),


来源:https://stackoverflow.com/questions/17442470/yii-get-mysql-query-executed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!