When there is an error with your sql statement in codeigniter you get a message a bit like this:-
A Database Error Occurred
Error Number: 1096
- some sql -
Filename: \system\database\DB_driver.php
Line Number: 334
Which is all well and good but when you’ve got lots of statements running for a single page it would help to know which line of code generated the query.
How do I get name of the model and method (or the filename) which generated the query?
I’m answering my own question here because I found a quick and dirty solution which works for debugging purposes. I highly recommend leaving CI system files in tact, this should only be used for debugging. I might write an extension for CI to do this when I’ve got time.
Solution for CI 2:-
Go and edit
system\database\DB_driver.phpand add the following code online 321:-