I just want to get the database error of my code and write an error log. but it shows this error message. my codeigniter version is 2.2.3 I user SQL Server as my database. How can I solve this.
Fatal error: Uncaught Error: Call to undefined method CI_DB_sqlsrv_driver::error()
try {
$this->db->trans_start(FALSE);
for ($i = 0; $i < 10; $i++) {
$data['Name'] = $i;
$this->mfunctions->insert('test1', $data);
}
for ($i = 0; $i < 10; $i++) {
$data['Name2'] = $i;
$this->mfunctions->insert('test2', $data);
}
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
throw new Exception($this->db->error());
echo "Fail";
} else {
echo "true";
}
} catch (Exception $e) {
$this->db->trans_rollback();
log_message('error', sprintf('%s : %s : DB transaction failed. Error no: %s, Error msg:%s, Last query: %s', __CLASS__, __FUNCTION__, $e->getCode(), $e->getMessage(), print_r($this->db->last_query(), TRUE)));
}