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
#2

I am not sure if I understand the problem. If you have an error in the query why dont you just fix the query?
What error are you seeing? And can you share the code you use to excecute the query?
On the package it said needs Windows 7 or better. So I installed Linux.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB