在Codeigniter下,是否可能看到mysql_error()?

时间:2022-08-29 22:45:29

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.

我有一个Codeigniter应用程序(使用2.1.0版本),它正在向mysql数据库编写事务。我很确定我有一个外键约束错误,但是我找不到办法让CI告诉我具体的错误。mysql_error()返回空。

Can anyone tell me how to get Codeigniter to tell me the mysql error message?

谁能告诉我怎么让Codeigniter告诉我mysql错误消息吗?

2 个解决方案

#1


36  

Yes, this is the mysql_error() wrapper.

是的,这是mysql_error()包装器。

$this->db->_error_message();

And the mysql_errno wrapper is:

mysql_errno包装器为:

$this->db->_error_number();

#2


2  

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

您可以在db类中使用call_function访问mysql_error:

http://ellislab.com/codeigniter/user-guide/database/call_function.html

http://ellislab.com/codeigniter/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:

当然,您也可以打开DB配置中的调试标志,告诉CI显示DB错误:

http://ellislab.com/codeigniter/user-guide/database/configuration.html

http://ellislab.com/codeigniter/user-guide/database/configuration.html

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

db_debug - TRUE/FALSE (boolean) -是否应该显示数据库错误。

#1


36  

Yes, this is the mysql_error() wrapper.

是的,这是mysql_error()包装器。

$this->db->_error_message();

And the mysql_errno wrapper is:

mysql_errno包装器为:

$this->db->_error_number();

#2


2  

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

您可以在db类中使用call_function访问mysql_error:

http://ellislab.com/codeigniter/user-guide/database/call_function.html

http://ellislab.com/codeigniter/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:

当然,您也可以打开DB配置中的调试标志,告诉CI显示DB错误:

http://ellislab.com/codeigniter/user-guide/database/configuration.html

http://ellislab.com/codeigniter/user-guide/database/configuration.html

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

db_debug - TRUE/FALSE (boolean) -是否应该显示数据库错误。