I am using $db->error() to catch SQL errors but when I use it with oracle it throws an error along with the HTML page and is unable to rollback. I already changed $db['default']['db_debug'] = false; but still getting HTML page.
$db = $this->load->database($db_name, TRUE);
$db->trans_begin();
$ret = array();
foreach ($query['query'] as $value) {
$db->query($value);
$error = $db->error();
if($error['message'] != null){
echo '<pre>';print_r($error);echo '</pre>';
array_push($ret,$error['message']);
}
}
if ($db->trans_status() === FALSE) {
$db->trans_rollback();
return $data['msg'] = $ret;
}else{
$db->trans_commit();
return $data['msg'] = true;
}
Code is working perfectly fine when getting SQL DB error and getting this error with oracle
<div style="border:1px solid #dd4814;padding-left:20px;margin:10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: oci_execute(): ORA-00001: unique constraint (C##TEST.PK_GROUPS) violated</p>
<p>Filename: oci8/oci8_driver.php</p>
<p>Line Number: 281</p>
<p>Backtrace:</p>
<p style="margin-left:10px">
File: C:\xampp\htdocs\gen-script-api\application\models\common_model.php<br />
Line: 297<br />
Function: query </p>
<p style="margin-left:10px">
File: C:\xampp\htdocs\gen-script-api\application\controllers\Common_Ctrl.php<br />
Line: 79<br />
Function: insert_to_ticket </p>
<p style="margin-left:10px">
File: C:\xampp\htdocs\gen-script-api\index.php<br />
Line: 308<br />
Function: require_once </p>
</div>
<pre>Array
(
[code] => 1
[message] => ORA-00001: unique constraint (C##TEST.PK_GROUPS) violated
[offset] => 0
)
</pre>["ORA-00001: unique constraint (C##TEST.PK_GROUPS) violated"]
I can see an error coming by $db->error() but how can I stop the HTML page from coming along with so i can receive this error from frontend?