• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database Connection Error Handling

#1
Hi,

Is it possible to handle database connection error in CodeIgniter?

I'm loading my database in my core controller using this method

PHP Code:
$this->load->database(); 

I want to handle it when it cannot connect to the specified database, like I want to display the error in json format with my custom error message. Instead of the default error message like below:

PHP Code:
A PHP Error was encountered
Severity
Warning

Message
mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using passwordNO)

Filenamemysqli/mysqli_driver.php

Line Number
203 

I will use it with my test REST Api, the reason I want to display the error message in json format.

CodeIgniter 3.1.11
LAMP Stack

Thanks!
Reply

#2
https://stackoverflow.com/questions/2574...gniter-php
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.