English 中文(简体)
Under Codeigniter, is it possible to see mysql_error()? [duplicate]
原标题:

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?

最佳回答

Yes, this is the mysql_error() wrapper.

$this->db->_error_message();

And the mysql_errno wrapper is:

$this->db->_error_number();
问题回答

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

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:

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

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





相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

What s the proper MVC way to do this....?

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I m actually using Kohana). I m new to MVC and don t want to get this wrong... so I m wondering if i have ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

CodeIgniter adding semicolons

How do I stop CodeIgniter adding semicolons ; to data sent via POST that contains ampersand &? For example it is converting "a=1&b=2&c=3" into "a=1&b;=2&c;=3". From looking on the forums ...

Best way to make Admin pages in CodeIgniter?

I m working on an app in CodeIgniter, and I want to have admin pages for several of the objects in the application, and I m wondering what would be the better way to put these into an MVC structure. ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签