From: Johannes Schwab Date: Fri, 4 Aug 2017 09:01:29 +0000 (+0200) Subject: Catch exceptions in PDO constructor X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=37262c24d91796246db5d7562b23925df6b9e39a;p=friendica.git Catch exceptions in PDO constructor --- diff --git a/include/dba.php b/include/dba.php index d921167c1d..9b69158e2b 100644 --- a/include/dba.php +++ b/include/dba.php @@ -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';