![]() |
MYSQL Error - How can I log the Query (not only _error_messge()) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: MYSQL Error - How can I log the Query (not only _error_messge()) (/showthread.php?tid=31281) |
MYSQL Error - How can I log the Query (not only _error_messge()) - El Forum - 06-13-2010 [eluser]ladooboy[/eluser] Hi Guys ! I am using active record for the query. I was wondering if there is any way logging the query which resulted in an error. _error_message() _error_number() Bother return to less information for the log. I need to know the exact query with the values, which caused a problem and I am struggling to log them. This information is usually shown on screen when DB debugging is enabled. MYSQL Error - How can I log the Query (not only _error_messge()) - El Forum - 06-13-2010 [eluser]siubie[/eluser] hi ![]() i never try to log the erorr but usually i use echo $this->db->last_query(); every time i got my query wrong and fix it one by one ![]() MYSQL Error - How can I log the Query (not only _error_messge()) - El Forum - 06-13-2010 [eluser]ladooboy[/eluser] Ah that's a nice trick. That's exactly what I needed. Thanks ![]() MYSQL Error - How can I log the Query (not only _error_messge()) - El Forum - 06-13-2010 [eluser]pickupman[/eluser] You may have some use for: Code: $this->output->enable_profiler(TRUE); This will append to the bottom of the page execution time, request array, DB queries, and session variables. MYSQL Error - How can I log the Query (not only _error_messge()) - El Forum - 06-13-2010 [eluser]ladooboy[/eluser] Thanks for the info. This was already enabled, but I just needed to log the query for error purposes later in live. PS: I am a little confused with mysql errors. When a user is trying to log in and all the insert/update etc. commands are executed. Some of them might fail for what ever reason, should I show this as a fatal error with show_error() and terminate the application or should I just log the error, but that means checking the success of EVERY query. Is this practical ? But then if lets say the session table wasn't updated properly or the user tables, this is a really major problem. Is it better to terminate the application in this instance ? I am currently trying to implement some DB exception etc. and I am really confused how to do the design and when exactly to call what errors. MYSQL Error - How can I log the Query (not only _error_messge()) - El Forum - 06-14-2010 [eluser]Ivar89[/eluser] It might NOT be practical no but thats when you can use enable_profiler so you see right away if it failed or not. MYSQL Error - How can I log the Query (not only _error_messge()) - El Forum - 06-14-2010 [eluser]ladooboy[/eluser] Hi ! Yes, but once the site is live I have to disable the profiler. What if such an error occures during the live time. I guess I have to check every select,update,insert,delete statement for errors... |