Yii Get MySql查询执行 [英] Yii Get MySql query executed
本文介绍了Yii Get MySql查询执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在保存,更新,删除之前执行MySql查询,以创建个人LOG(审核).
I need get the MySql query executed before Save, Update, Delete for create a personal LOG (audit).
我使用CActiveRecord的$ model-> save()和$ model-> delete()标准.
I use $model->save() and $model->delete() standard from CActiveRecord.
有人知道我该怎么做吗?
Any know how i can do this?
谢谢大家!
推荐答案
您可以使用方法
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也可以通过取消注释config.main文件中的以下代码来查看页面上的日志
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',
),
这篇关于Yii Get MySql查询执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文