active record and errors - 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: active record and errors (/showthread.php?tid=14237) |
active record and errors - El Forum - 12-24-2008 [eluser]akkumaru[/eluser] Hi, all,, I want to know How to catch all kind of possible errors when i'm using Active Record,, e.g. How do I know an insertion or update is failed so that I can set up an error handling strategy? Or How do I know a database error occures while prevent the CI error message to be written to the page, so that I can set up my error handling strategy? I've tried the try{}catch(Exception $e){} clause,, but it seems it didn't work,, active record and errors - El Forum - 12-25-2008 [eluser]bitist[/eluser] I modified the DB_driver.php, look for function query( ... You'll find there this code: Code: // grab the error number and message now, as we might run some So the variables $error_no and $error_msg contain the specific mysql error descriptions. You can use it to write out to a file or just simply create a popup window and display it. Don't forget to activate the $db['default']['db_debug'] = true; in database.php config file. active record and errors - El Forum - 12-27-2008 [eluser]akkumaru[/eluser] thank you devpedia,, but is there any 'safer' way? i'm new to CI and don't really think I should touch the system folder,, active record and errors - El Forum - 12-27-2008 [eluser]bitist[/eluser] I don't see other way. In the query function, when an error occure, the display_error() will be called and there is an Code: exit(); So you could change only this display_error() function and write a file when an error occure. It's not a big deal, I've modified this file, I get an email on any error and write a log file too. But fortunately I don't really have errors ;-) active record and errors - El Forum - 12-29-2008 [eluser]akkumaru[/eluser] ,,i see, i may try this then,, oh, by the way,, it seems that i cannot use the database class' transaction like this: Code: $this->load->model("model1","",TRUE); first update will not be rolled back even when the second is failed.. how to solve this? |