How can I intercept database requests error? |
[eluser]FordEscort[/eluser]
I have just started working with Code Igniter a while and I think it's very interesting. I'm facing a problem with handling errors. When running requests that produce database errors (duplicate entry violation for example), the script is exiting and displays the error. I want to do something like this : Code: if ($this->db->update('MyTable', $arrCol)) So that the script is not stopped. Is this possible?; Thanks.
[eluser]n0xie[/eluser]
If you are using PHP5 you could use a try-catch block: http://us3.php.net/manual/en/language.exceptions.php which let's your application recover from errors.
[eluser]rogierb[/eluser]
You can turn DB_DEBUG to false and catch the error yourself like n0xie said. Only I would use mysql_error() assuming you use mysql.
[eluser]FordEscort[/eluser]
It works fine when setting db_debug to false. Thanks a lot. |
Welcome Guest, Not a member yet? Register Sign In |