0

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 Answer 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',
                ),
Sign up to request clarification or add additional context in comments.

7 Comments

Yes, i know it, but my question is: How i can get the SQL Query executed?
what is the query that u want to execute ??
i want get the query executed. Ex: I do $model->save(); I want have a log of the "save" query executed. Ex: INSERT INTO user VALUES('xx'); I need this sql query.
I mean u want the details of the query ?? please clear your question i am bit confused
yes yes, i need the details of the query. Because if i do $model->save() i don't know which is the executed statement, and i need write the sentence in a audit table (All insert and delete executed querys.)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.