logging database queries |
[eluser]Unknown[/eluser]
Been looking at db_debug and stuff like that, but I don't find and obvious way to log all database queries to a file. In fact I wan't only to log any query that modifies the database. Any suggestions on how to achieve this? All my application code uses actice record so I was thinking of extending that class, so the methods that imply update, insert, delete would log the SQL query automtically. But since the active record class is not a library, I don't believe I can extend it in the application/libraries folder the standard way. How can I avoid modifying the CodeIgniter source and still achieve this? An I don't want to rely on manualy adding logging statements in the controller code itself.
[eluser]gunter[/eluser]
just a suggestion: the profiler class shows all your queries if you want... you could check, how it is done and copy and modify the profiler library to your purpose so it´s logging the query instead of displaying it... and make it a post controller hook... what a great idea...
[eluser]mezoni[/eluser]
Look at Profiler library code. Code: if (class_exists('CI_DB_driver')) Look at DB_Driver code. Code: $this->queries[] = $sql;
[eluser]Unknown[/eluser]
We just solved this problem by using an hook on "post_controller". http://ellislab.com/codeigniter/user-gui...hooks.html Its quit easy, you can handle all databasequerys from inside the hook by using: Code: this->CI =& get_instance(); |
Welcome Guest, Not a member yet? Register Sign In |