Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Under Codeigniter, is it possible to see mysql_error()?

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?

like image 246
pbarney Avatar asked Jul 13 '10 06:07

pbarney


People also ask

How do you check data is inserted or not in CodeIgniter?

How do you check data is inserted or not in CodeIgniter? You can use $this->db->affected_rows() function of codeigniter.

How can I get database error in CodeIgniter 3?

$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.


1 Answers

Yes, this is the mysql_error() wrapper.

$this->db->_error_message();

And the mysql_errno wrapper is:

$this->db->_error_number();
like image 148
Bella Avatar answered Oct 19 '22 09:10

Bella