stefangabos/Zebra_Database

Catch error on $db->connect

Closed this issue · 4 comments

I need to get an error if db connection fails.
But I can't catch any error on connection of database $db->connect, I've tried TryCatch statement and $db->connect(...) or die($db->error()) which doesn't work.

Even this solution returns an error :
https://stackoverflow.com/a/45950465/10723857

Fatal error: Uncaught mysqli_sql_exception: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

the error is shown in the debug console. or do you want to handle it differently?

I need to get it either from an property or a method of $db

Do you mind if I open a pull request to implement this feature ?

Please do.
I don't know if this helps otherwise