![]() |
How to return database errors ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to return database errors ? (/showthread.php?tid=23331) |
How to return database errors ? - El Forum - 10-07-2009 [eluser]bhenbe[/eluser] Hello all, this is my first post here and sorry for my english (i'm belgian). Here's my problem : i want to show the returned error from a database transaction. I use html parser. My code : Model : Code: function service_add_user($service_id, $user_id) { Controller : Code: function service_add_user($service_id) { View : Code: {messages} Thank you for your help ! How to return database errors ? - El Forum - 10-07-2009 [eluser]rogierb[/eluser] try: $this->db->_error_message() En welkom :-) How to return database errors ? - El Forum - 10-07-2009 [eluser]bhenbe[/eluser] Thank you ;-) I tried this function but it does'nt work. Here's the response with db debug on : Quote:Error Number: 1054 (i used a syntax error to test...) When i set debug off, i have no response with Code: function service_add_user($service_id) { How to return database errors ? - El Forum - 10-07-2009 [eluser]InsiteFX[/eluser] It's in the CodeIgniter user guide! CodeIgniter user guide Enjoy InsiteFX How to return database errors ? - El Forum - 10-07-2009 [eluser]bhenbe[/eluser] I'm sorry but i don't find any function example wich return a sql error. I already read the user guide. I thought i can find an answer in the Managing Errors chapter : Quote:if ($this->db->trans_status() === FALSE) Perhaps, i need to translate this page to understand... CI manages sql error without debug mode or not ? Thank you. How to return database errors ? - El Forum - 10-07-2009 [eluser]rogierb[/eluser] You have to catch the error in your model after the query. There will be no error after a succesfull transaction rollback. As for custom error handling being in the userguide, I'm still looking... The only thing I've found is that you can controle the message, not the message itself. Can be blind though... ![]() How to return database errors ? - El Forum - 10-07-2009 [eluser]bhenbe[/eluser] Quote:You have to catch the error in your model after the query. There will be no error after a succesfull transaction rollback. Thanks ! |