Log queries

Login or register to post comments
7 replies [Last post]
Offline
Joined: 06/21/2010

How can I log all the queries in a single file ?
QApplication::$Database[1]->OutputProfiling() is a good start but i don't want to click on a link to see the queries.

Thanks

alex94040's picture
Offline
Joined: 11/06/2008

Do you want to log the queries for development purposes (i.e. try to make individual pages faster)? Or for some other reason?

Offline
Joined: 06/21/2010

For example I need to log all the INSERT queries and on production I can't activate the profiler.

alex94040's picture
Offline
Joined: 11/06/2008

Ummm how exactly are you planning to use the results of this log? Is this for auditing purposes? I.e. to see which user did what operation?

Can you give the desired format of the log? Is it something like this:

Timestamp QuerySQL

Or something fancier, like

Timestamp UserID QuerySQL

Offline
Joined: 06/21/2010

Timestamp QuerySQL should be enough.

I can't activate mysql logging and I found a way to use the generated model and extend it but because columns can change to the table I don't want to update the extended class manually with the new fields each time.

Do you have any suggestions?

alex94040's picture
Offline
Joined: 11/06/2008

Write your own database adapter class that extends from one of the existing classes. In that class, override the LogQuery method to write to the file.

Offline
Joined: 06/21/2010

Great solution.
Thank you

alex94040's picture
Offline
Joined: 11/06/2008

My pleasure. Best of luck to you!