(01-22-2016, 08:18 AM)ComputingFroggy Wrote: I've tracked down the problem to the display_error method in system/database/DB_driver class.
At line 1704 (last line of the method), there's :
PHP Code:
exit(8); // EXIT_DATABASE
So, no wonder each time there's a database error, the application does not go any further: it just stops there !
I commented out this line, and now I do receive an exception and the return of the insert method from my model returns true or false (according to success or failure).
May be that's something that should be considered in the standard CodeIgniter code base.
Cheers,
L@u
First off--bad idea to be changing the driver!
Instead, you need to set db_debug to false in your database.php in the config directory:
This will stop codeigniter from displaying the error automatically
In your model function check for success and explicitly throw an error if the insert returns false.
PHP Code:
public function insert($pRow) {
if (!$this->db->insert( 'P', $pRow)) {
$error = $this->db->error();
throw new Exception('model_name->record: ' . $error['code'] . ' ' . $error['message']);
}
return TRUE;
}
In your controller catch statement you want log the error->message, but not display it to the user, because it can
reveal details of your database that you may not want public.
PHP Code:
} catch (Exception $e) {
log_message('error', $e->getMessage());
echo 'Received exception : ', 'friendly detail', "\n";
}