Welcome Guest, Not a member yet? Register   Sign In
Custom handling of DB errors
#1

Hi,

In my application I have some database insert/update operations that are triggered by ajax calling the appropriate controller.

If the query is successful the model returns:
PHP Code:
$data['result'] = 1

or if it fails it returns:

PHP Code:
$data['result'] = 0;
$data['err' = $this->db->_error_number();
$data['msg' = $this->db->_error_message();
$data['query' = $this->db->last_query(); 


Controller return this as a json string, and then I want to handle those in my own way from the front-end.

I have set the db_debug in database config file to false, but when the query fails for any reason I just get the PHP error page being returned with the below message, which obviously hangs the ajax request because it is expecting json data, and even if I set it to html I would still get a CI PHP error messages.


Quote:Message: pg_query(): Query failed: ERROR:.....


How can I simply return the database errors without displaying the PHP error pages?
Reply


Messages In This Thread
Custom handling of DB errors - by topper - 08-18-2017, 01:29 AM
RE: Custom handling of DB errors - by rtenny - 08-18-2017, 07:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB