Codeigniter returning code 0 db errors without message

Home / Uncategorized / Codeigniter returning code 0 db errors without message

Question:
I have a query that is supposed to return an error message like this:Error Number: 1451

Cannot delete or update a parent row: a foreign key constraint fails (`sservice_dev_mercury`.`agent_accounts`, CONSTRAINT `agent_role_fk` FOREIGN KEY (`role`) REFERENCES `roles` (`id`))

DELETE FROM `roles` WHERE `id` = ‘3’
This is when db_debug is true. When I turned it false and used
$error = $this->db->error();
return $error;
I get error 0 with an empty message. Is there something I am missing when trying to get the errors? This is the query:public function delete($id){
$this->db->trans_begin();
$this->db->where(‘id’,$id);
$this->db->delete($this->table);
$this->db->trans_complete();
if($this->db->trans_status()===false){
$this->db->trans_rollback();
$error = $this->db->error();
return $error;
}else{
$this->db->trans_commit();
return true;
}
}
Can someone take a look and see if something went wrong?


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *