0

我需要在保存、更新、删除之前执行 MySql 查询以创建个人日志(审核)。

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

知道我该怎么做吗?

谢谢大家!

4

1 回答 1

2

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',
                ),
于 2013-07-03T08:57:06.423 回答