Hi,
Is it possible to handle database connection error in CodeIgniter?
I'm loading my database in my core controller using this method
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 password: NO)
Filename: mysqli/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!