]> git.mxchange.org Git - friendica.git/commitdiff
Catch exceptions in PDO constructor
authorJohannes Schwab <mail@jschwab.org>
Fri, 4 Aug 2017 09:01:29 +0000 (11:01 +0200)
committerJohannes Schwab <mail@jschwab.org>
Fri, 4 Aug 2017 09:01:29 +0000 (11:01 +0200)
include/dba.php

index d921167c1ded9fcfb21f5416666de3c4754edd04..9b69158e2b6e575fff009561cbafe4038d148ca5 100644 (file)
@@ -75,9 +75,11 @@ class dba {
                        if (isset($a->config["system"]["db_charset"])) {
                                $connect .= ";charset=".$a->config["system"]["db_charset"];
                        }
-                       $this->db = @new PDO($connect, $user, $pass);
-                       if (!$this->db->errorCode()) {
+                       try {
+                               $this->db = @new PDO($connect, $user, $pass);
                                $this->connected = true;
+                       } catch (PDOException $e) {
+                               $this->connected = false;
                        }
                } elseif (class_exists('mysqli')) {
                        $this->driver = 'mysqli';