Undefined property: PDO::$connect_error

后端 未结 3 1088
孤城傲影
孤城傲影 2021-01-26 08:10

I am trying to use $dbc->connect_error to check if any error occurs while trying to connect to my databease. I always get an error page saying:

3条回答
  •  星月不相逢
    2021-01-26 09:04

    If we have a look at the PDO manual and look up for the PDO class there is no connect_error property anywhere. But if we check mysqli manual we see it right there. You have to choose a database library and stick to it, they cannot be mixed.

    I always recommend to configure PDO to throw exceptions as you already do (although connection errors in particular will always through an exception no matter your settings) and not care to catch them unless you want to do something specific with them.

提交回复
热议问题