Codeigniter Mysql Query Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this codeigniter mysql error handling site About Us Learn more about Stack Overflow the company Business Learn more
Codeigniter Query Error Handling
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
Codeigniter Active Record Error Handling
Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Under Codeigniter, is
$this- Db- Query Codeigniter
it possible to see mysql_error()? up vote 13 down vote favorite 9 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 codeigniter get mysql error how to get Codeigniter to tell me the mysql error message? mysql codeigniter transactions share|improve this question edited Sep 21 '14 at 6:15 infused 14.6k113150 asked Jul 13 '10 at 6:02 pbarney 83321630 add a comment| 2 Answers 2 active oldest votes up vote 32 down vote accepted Yes, this is the mysql_error() wrapper. $this->db->_error_message(); And the mysql_errno wrapper is: $this->db->_error_number(); share|improve this answer answered Jul 13 '10 at 6:40 DRL 2,683919 In the current version of CI, those are private functions. Any suggestions on the best way to get access to them with modifying the core files? –pbarney Mar 27 '15 at 19:57 add a comment| up vote 2 down vote 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. share|improve this answer edited Mar 26 '14 at 5:17 answered Jul 13 '10 at 6:05 Amber 245k36410414 When I attempt to use call_function('mysql_error'), I get the followi
Chart Model-View-Controller Architectural Goals Tutorial Static pages News section Create news items Conclusion Contributing to CodeIgniter Writing CodeIgniter Documentation Developer's Certificate of Origin 1.1 General Topics CodeIgniter URLs codeigniter query string Controllers Reserved Names Views Models Helpers Using CodeIgniter Libraries Creating Libraries codeigniter try catch Using CodeIgniter Drivers Creating Drivers Creating Core System Classes Creating Ancillary Classes Hooks - Extending the this db query codeigniter example Framework Core Auto-loading Resources Common Functions Compatibility Functions URI Routing Error Handling Caching Profiling Your Application Running via the CLI Managing your Applications Handling Multiple Environments Alternate http://stackoverflow.com/questions/3234564/under-codeigniter-is-it-possible-to-see-mysql-error PHP Syntax for View Files Security PHP Style Guide Libraries Benchmarking Class Caching Driver Calendaring Class Shopping Cart Class Config Class Email Class Encrypt Class Encryption Library File Uploading Class Form Validation FTP Class Image Manipulation Class Input Class Javascript Class Language Class Loader Class Migrations Class Output Class Pagination Class Template Parser Class https://www.codeigniter.com/userguide3/database/queries.html Security Class Session Library HTML Table Class Trackback Class Typography Class Unit Testing Class URI Class User Agent Class XML-RPC and XML-RPC Server Classes Zip Encoding Class Database Reference Quick Start: Usage Examples Database Configuration Connecting to a Database Running Queries Generating Query Results Query Helper Functions Query Builder Class Transactions Getting MetaData Custom Function Calls Query Caching Database Manipulation with Database Forge Database Utilities Class Database Driver Reference Helpers Array Helper CAPTCHA Helper Cookie Helper Date Helper Directory Helper Download Helper Email Helper File Helper Form Helper HTML Helper Inflector Helper Language Helper Number Helper Path Helper Security Helper Smiley Helper String Helper Text Helper Typography Helper URL Helper XML Helper CodeIgniter Welcome to CodeIgniter Installation Instructions Downloading CodeIgniter Installation Instructions Upgrading From a Previous Version Troubleshooting CodeIgniter Overview Getting Started CodeIgniter at a Glance Supported Features Application Flow Chart Model-View-Controller Architectural Goals Tutorial Static pages News section Create news items Conclusion Contributing to CodeIgniter Writing CodeIgniter Documentation Developer's Certifi
Vote(s) - 0 Average 1 2 http://forum.codeigniter.com/thread-63976.html 3 4 5 Thread Modes get mysql errors text mstdmstd Junior Member Posts: 21 Threads: 13 Joined: Dec 2015 http://www.joshuawinn.com/launching-your-codeigniter-site-disable-database-errors/ Reputation: 0 #1 12-29-2015, 09:12 AM Hello, Making rest api using CodeIgniter 3.0.3 I want in case of mysql error handling error to return error description in json return block In case of PHP Code: db_debug=true
I get error message like on my screen : PHP Code: ErrorNumber:1054
Unknowncolumn'userna'in'fieldlist'
SELECT`id`,`userna`FROM`bp_users`ORDERBY`username`ASCLIMIT4,2
Filename:models/Muser.php
LineNumber:219
if PHP Code: db_debug=false
I did not find how to log these errors. I googled and found : PHP Code: $this->db->call_function('error')and$this->db
Tutorials & Guides | Tagged: CodeIgniter, PHP, Security Turning off error reporting is often mentioned as a standard security precaution when switching to a production environment. After all, you don't want those precious database table and field names out in the open, for sneaky little hobbitses to view. If someone is rummaging through your site, trying to find vulnerabilities, this severely limits the information they have at their disposal. This of course falls into security-through-obscurity, which isn't going to fix bad code (see the last section below for more about designing code to fail gracefully). It merely fogs the windows to your infrastructure a little. Hackers sometime search Google for pages that have been indexed with MySQL errors on them. They are like a giant red flags, waving boldly in the wind, that read ‘Possible Vulnerability Here'; While a folded ‘On Vacation!' note sits atop the webmaster's chair. Plus, from a visual rather than a security standpoint, who wants to see a big ol' nasty MySQL error when something goes wrong? Alright, you know it's a good idea already. Your CodeIgniter site is launched or is on the verge of doing so, but how do you turn off the errors? There are three Codeigniter files that need to be modified: 1. Turn off PHP Errors with error_reporting(0) In the root directory of your CodeIgniter install, there is an index.php file. The first option in there is ‘PHP ERROR REPORTING LEVEL'. Set it to zero: error_reporting(0); CodeIgniter version 2.0.1 and above have an environment constant in the index.php file as well. Setting this to "production" will disable all PHP error output. Read more about this on the Codeigniter User Guide page on Security and on Handling Environments. 2. Turn off Database Errors in Config The PHP errors are off, but any MySQL errors are still going to show. Turn these off in the /config/database.php file. Set the db_debug option to false: $db['defaul