I have an Codeigniter app (using version 2.1.0) that is writing a transaction to a mysql database. I'm fairly sure that I've got a foreign key constraint error occurring, but I can find no way to make CI tell me the specific error. mysql_error() comes back empty.
Can anyone tell me how to get Codeigniter to tell me the mysql error message?
How do you check data is inserted or not in CodeIgniter? You can use $this->db->affected_rows() function of codeigniter.
$query = "some buggy sql statement"; $this->db->db_debug = false; if(!@ $this->db->query($query)) { $error = $this->db->error(); // do something in error case }else{ // do something in success case } ... Save this answer.
Yes, this is the mysql_error() wrapper.
$this->db->_error_message();
And the mysql_errno wrapper is:
$this->db->_error_number();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With