Welcome Guest, Not a member yet? Register   Sign In
Log queries for auditing purposes

I am building an application where there is the need to keep track of all changes made to the data stored in the db, for auditing purposes. Is there any way to retrieve a query built by Active Records, so that it can be logged somewhere? I can't just rely on the MySQL server log files, as I also need to log other information that wouldn't be available there.


You can use
to findout the last run query.

Happy Coding,

I think if you enabled the Profiler you will see all queries been made.

User Guide :

Thanks, both of you. In the end, thanks to the fact that I am using PHP5, the solution was much easier than I thought.

I noticed that $this->db->queries would show me all the queries executed by a controller. Since I had already created a MY_Controller class, which all other controllers were extending, I simply added a __destruct() method where I look for all insert/update/delete queries and log them to the db, along with other information I need.

There might be better and more elegant ways to accomplish the task, but this will do just fine for me.

Theme © iAndrew 2016 - Forum software by © MyBB