views:

33

answers:

2

I have an Codeigniter app (latest version of CI) 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 myslq error message?

+1  A: 

You may be able to use call_function in the db class to access mysql_error:

http://codeigniter.com/user_guide/database/call_function.html

Of course, you could also just turn on the debug flag in the DB config, to tell CI to display db errors:

http://codeigniter.com/user_guide/database/configuration.html

db_debug - TRUE/FALSE (boolean) - Whether database errors should be displayed.

Amber
When I attempt to use call_function('mysql_error'), I get the following:"This feature is not available for the database you are using."It is an innodb table under mysql.I do have $db['default']['db_debug'] = TRUE in the database.php config file.The most I get is my exception and a stack trace.This is so frustrating. Right now, I'm feeling like going with CI was a big mistake.
pbarney
@pbarney dont give up on it yet, check my answer
DRL
Also note, as mentioned on the `call_function` page, you're supposed to pass the name of the function **without** the `mysql_` prefix.
Amber
+3  A: 

Yes, this is the mysql_error() wrapper.

$this->db->_error_message();

And the mysql_errno wrapper is:

$this->db->_error_number();
DRL