Welcome Guest, Not a member yet? Register   Sign In
Best place to intercept *all* DB calls
#1

[eluser]jedd[/eluser]
I want to be able to make a log of all DB calls - probably straight to a text file, just using a couple of bits of session information (user, time) and the literal string made to the DB. So probably about 5 lines of code.

Where's the best place to put such an intercept?

JIC, would there be any change to the answer if I wanted to log to a DB table (still using the app's DB) instead?
#2

[eluser]TheFuzzy0ne[/eluser]
It depends just where you need to intercept these calls. You could override the Loader's database() method, and have it load you're own DB.php, or you can override the Loader's database() method and have it load you're own database driver file. [url="http://codeigniter.com/wiki/Extending_Database_Drivers/"]See here for more information on extending/overriding database drivers.[/url]
#3

[eluser]pistolPete[/eluser]
You could
- use Hooks
- extend the Model class and add the logging functionality into MY_Model.php
- extend the database class
- extend the Logging Class
#4

[eluser]TheFuzzy0ne[/eluser]
I have no idea how you'd achieve that by using hooks, extending the model, or extending the logging class. I am intrigued though. Are there any examples of this?




Theme © iAndrew 2016 - Forum software by © MyBB