PDO catch PDOException fails on construction

前端 未结 2 420
情话喂你
情话喂你 2021-01-27 17:26

I\'ve seen variations of this code all over the place, including many S.O. posts:

class db extends PDO {

    public function __construct( $dbconf ) {
        $o         


        
2条回答
  •  温柔的废话
    2021-01-27 17:48

    The reason being is PDO::__construct only creates the object upon successful connection. So when you call the parent constructor and it fails your object doesn't exist anymore. You should use self::myerror() to access the error function statically in this case.

提交回复
热议问题