Daniel Vaquero
Daniel Vaquero

Reputation: 1305

Yii Get MySql query executed

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!

Upvotes: 0

Views: 1312

Answers (1)

Ninad
Ninad

Reputation: 1871

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',
                ),

Upvotes: 2

Related Questions