CodeIgniter onDBError returning Codeigniter error

Hello, I have using Codeigniter (CI) with DHTMLX

Because I don’t know how to “attachEvent” to FormConnector with Codeigniter, so I am trying by myself

When I am inserting correct data, AfterInsert Event returning value is OK (nama_dokter).
When I am trying insert duplicate data on unique field, error message shown CodeIgniter error, not call onDBError function

Please help me if anything error with my code :

[code]<?php
defined(‘BASEPATH’) OR exit(‘No direct script access allowed’);

use Dhtmlx\Connector\GridConnector;
use Dhtmlx\Connector\FormConnector;
use Dhtmlx\Connector\ComboConnector;

class Dokter extends CI_Controller {

public function grid() {
	$dokterGrid = new GridConnector($this->db, "PHPCI");
	$sql = "SELECT * FROM dokter";
	$dokterGrid->dynamic_loading('20');
	$dokterGrid->render_sql($sql, 'kode_dokter', 'nama_dokter,spesialis,alamat_dokter,no_tlp');
}

public function form() {
	$formdata = new FormConnector($this->db, "PHPCI");
	$formdata->event->attach(new dokterEvent());		
	$formdata->render_table('dokter', 'kode_dokter', 'nama_dokter,spesialis,alamat_dokter,no_tlp');
}

}

class dokterEvent {
public function afterUpdate($action) {
$nama_dokter = $action->get_value(‘nama_dokter’);
$action->set_response_text($nama_dokter);
}
public function afterInsert($action) {
$nama_dokter = $action->get_value(‘nama_dokter’);
$action->set_response_text($nama_dokter);
}

public function onDBError($action, $exception){
	$msg = $exception->getMessage();
	$action->set_response_text($msg);
}

}

?>[/code]

Thanks


Oh…God…solved by myself

I just need to change index.php CodeIgniter

from
define(‘ENVIRONMENT’, isset($_SERVER[‘CI_ENV’]) ? $_SERVER[‘CI_ENV’] : ‘development’);

to
define(‘ENVIRONMENT’, ‘production’);

With this step instead exception error message generated by CI (picture), I just get “CI - sql execution failed”
And dataProcessor can catch that error

Note: I’m using Codeigniter 3.1.3