How to disable A Database Error Occurred in Codeigniter

Source: Internet
Author: User
Tags php error codeigniter

By default, CodeIgniter displays all PHP errors. But when your development program ends, you may want to change this situation.
You will find this function error_reporting () at the top of the index. php file, through which you can set errors. Even if you disable the Error Report, the error record will not stop when an error occurs.
Therefore, modifying php. ini cannot achieve the desired effect.

The solution is as follows:

1. disable A Database Error Occurred Error prompt in Codeigniter

As mentioned in the CodeIgniter User Guide, setting the ENVIRONMENT constant to 'development' will allow all PHP error reports to be output to the browser. Conversely, setting the constant 'production 'will disable the output of all error reports.

Modify error_reporting in index. php:
Copy codeThe Code is as follows:
Define ('Environment ', 'production'); // The default value is development.
If (defined ('enable '))
{
Switch (ENVIRONMENT)
{
Case 'Development ':
Error_reporting (E_ALL );
Break;

Case 'testing ':
Case 'production ':
Error_reporting (0 );
Break;

Default:
Exit ('the application environment is not set correctly .');
}
}

2. disable a php Error was encountered Error prompt in Codeigniter

Modify database settings in config/database. php:
Copy codeThe Code is as follows:
$ Db ['default'] ['db _ debug'] = FALSE;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.