Welcome Guest, Not a member yet? Register   Sign In
Logging Mysql Queries
#1

[eluser]Unknown[/eluser]
I use Expression Engine, but would like to create a plugin for logging all MySQL Queries made on a dev server. I figured this would probably be something to do at the codeigniter level. The idea is to take the live database and run the sql queries that were made against the dev database on the live database for when I do a push of the new data. There are a lot of caveats I know, but I was just wondering if there is a simple tool to log the queries and store them in a db or write to a file. ( I know mysql has some logging functionality but I would like to do it from the software end.
#2

[eluser]spaquet[/eluser]
Have a look here http://ellislab.com/codeigniter/user-gui...iling.html and see if this answers your question.
#3

[eluser]Unknown[/eluser]
I just ended up writing my own function to store all WRITE queries into the DB. Thanks though for the article
#4

[eluser]InsiteFX[/eluser]
Code:
$this->db->last_query();

Returns the last query that was run (the query string, not the result). Example:

InsiteFX
#5

[eluser]fedeisas[/eluser]
A few weeks ago I ran into the very same problem. I wanted to log every query of each request, to benchmark and optimize some pieces of the site. After researching a little bit, I came up with my own solution. I've posted it here.

Also, I have modified my Log Library, in order to be able to write my own, separate, log files. Codeigniter writes his own, messy, log, and I write other files called database-20110528.php or cron020110528.php.

The important thing here is that CI stores every query (and time) in the main $CI object.

Let me know if you need more help.

Happy coding!




Theme © iAndrew 2016 - Forum software by © MyBB