Welcome Guest, Not a member yet? Register   Sign In
Show line number that triggered database error.
#1

[eluser]nicholas.byfleet[/eluser]
I am about ready to pull my hair out. When there is a database error, does anyone know how to print the line # and file that triggered the database error. I am building quite a complicated application and the standard error is practically useless for debugging purposes. Your input would be greatly appreciated. Thanks.
#2

[eluser]kulldox[/eluser]
I'm doing a little trick for solving such issues.
I'm placing the following code in every method of my controllers:
Code:
log('debug',__FILE__.', '.__LINE__.', '.__CLASS__.'/'.__METHOD__.'/'.__FUNCTION__.'');

This way I know at least what happened before or after that DB error.

Hope this helps.

Sure to this will be sent to log files Smile
#3

[eluser]InsiteFX[/eluser]
You can find all of this in the CodeIgniter users guide.

users guide error handling

Enjoy
InsiteFX
#4

[eluser]nicholas.byfleet[/eluser]
Thanks for the link, however this only explains how to show an error. I am trying to find a way to display the line # and file of the controller or model that actually triggered the error. Does that make sense?
#5

[eluser]InsiteFX[/eluser]
There are no line numbers that you can display unless you create them.

Why not just use a log file and output the the function name.

Enjoy
InsiteFX
#6

[eluser]kulldox[/eluser]
You could actually do something I wrote before for DB, for ex after every mysql query:

Code:
// here goes the query itself
// then check if there is any error
if(mysql_error()){
    // log the filename and line nuber and all the stuff to the log file
    log_message('debug',__FILE__.', '.__LINE__.', '.__CLASS__.'/'.__METHOD__.'/'.__FUNCTION__.'');
}

Something like this should do the trick.

Or you can use transactions like in the user guide here http://ellislab.com/codeigniter/user-gui...tions.html
#7

[eluser]Rob Corley[/eluser]
Have a look at this quick and dirty solution:-

http://stackoverflow.com/questions/10259...odeigniter




Theme © iAndrew 2016 - Forum software by © MyBB