Codeigniter Db Error Handling
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta codeigniter try catch database error Discuss the workings and policies of this site About Us Learn more codeigniter db error message about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Codeigniter Query Error Handling
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you,
Codeigniter Active Record Error Handling
helping each other. Join them; it only takes a minute: Sign up Codeigniter: How to handle database error? up vote 0 down vote favorite I'm creating a web application using codeigniter and postgresql. I have this inside my database: user id name unique(name) When someone try to register with the same name, i get an error. How can codeigniter try catch i handle them, without displaying the codeigniter's error and showing instead my custom error? If i set $db['default']['db_debug'] = FALSE; i don't get any error of course, but is there a way to handle the db error or should i check myself if the table already contains an entry with that same name? codeigniter debugging share|improve this question asked Oct 10 '14 at 9:34 Federico Ponzi 86411334 migrated from webmasters.stackexchange.com Oct 10 '14 at 10:31 This question came from our site for pro webmasters. add a comment| 3 Answers 3 active oldest votes up vote 0 down vote accepted I dont know anything by codeigniter, but im going to assume the principle works the same: You first make a query like SELECT id FROM tablename WHERE name='SomeName' LIMIT 1, then you check the number of rows. This kind of checking is fairly normal. Control as much as you (sensebly) can to avoid errors down the road. Zero rows? Safe to insert. Not zero rows? Display something like 'username allready ta
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 Controllers Reserved Names
Codeigniter Error Handling
Views Models Helpers Using CodeIgniter Libraries Creating Libraries Using CodeIgniter Drivers codeigniter error handling example Creating Drivers Creating Core System Classes Creating Ancillary Classes Hooks - Extending the Framework Core Auto-loading Resources call to undefined method ci_db_mysql_driver::_error_message() Common Functions Compatibility Functions URI Routing Error Handling Caching Profiling Your Application Running via the CLI Managing your Applications Handling Multiple Environments Alternate PHP Syntax for View Files http://stackoverflow.com/questions/26297374/codeigniter-how-to-handle-database-error 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 Security Class Session Library HTML Table Class Trackback https://www.codeigniter.com/user_guide/general/errors.html 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 Certificate of Origin 1.1 General Topics CodeIgniter URLs Controllers Reserved Names Views Models Helpers Using Cod
full version with proper formatting. RastoStric02-23-2015, 04:03 AM I am aware of the discussions on this topic in the CI forum, StackOverflow and elsewhere. I tried to do my research error handling carefully but it seems to me, that I did not find a proper answer. The question is how to handle database transaction errors and not to loose the error details. The codeigniter db error CI guide suggested way is PHP Code: $this->db->trans_start();
$this->db->query('ANSQLQUERY...');
$this->db->query('ANOTHERQUERY...');
$this->db->trans_complete();
if($this->db->trans_status()===FALSE)
{
//generateanerror...orusethelog_message()functiontologyourerror