CI4: how to check DB connection? |
Hi evryone!!! I have small trouble with how to right way check database connection. In my case I do this way:
PHP Code: public function checkDBConnection( array $DBConfig = [] ) : bool { But I am not sure in this way. Please need advice or comment with right descision. Thanks
I don't know that there is a right way, but one possibility is to use \CodeIgniter\Database\Config::getConnections(), which "Returns an array of all db connections currently made."
Don't we have a better solution for this? It seems that \CodeIgniter\Database\Config::getConnections() is not returning the actual connections but the predefined connection properties. Even if you input a wrong database name in the .env or Database.php file, it is still getting returned by this function
|
Welcome Guest, Not a member yet? Register Sign In |