From 339765bf0e4c9c868c7d46416c7f69e81b2a7717 Mon Sep 17 00:00:00 2001 From: Nick Liu Date: Tue, 26 May 2020 18:55:47 -0500 Subject: [PATCH] e_db_pdo: Throw exception instead of fatal erroring on connect fail Now e_db_pdo failures to connect to the database are catchable --- e107_handlers/e107_class.php | 2 +- e107_handlers/e_db_pdo_class.php | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index fc93d457e..621429f13 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1363,7 +1363,7 @@ class e107 * $instance_id * * @param string $instance_id - * @return e_db_mysql + * @return e_db */ public static function getDb($instance_id = '') { diff --git a/e107_handlers/e_db_pdo_class.php b/e107_handlers/e_db_pdo_class.php index 5a4437a10..1e73bf01b 100644 --- a/e107_handlers/e_db_pdo_class.php +++ b/e107_handlers/e_db_pdo_class.php @@ -2808,19 +2808,11 @@ class e_db_pdo implements e_db */ private function _getMySQLaccess() { - /*if (!$this->mySQLaccess) { - global $db_ConnectionID; - $this->mySQLaccess = $db_ConnectionID; - debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2); - - }*/ - if (!$this->mySQLaccess) { - // debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2); - $this->connect($this->mySQLserver, $this->mySQLuser, $this->mySQLpassword); - $this->database($this->mySQLdefaultdb, $this->mySQLPrefix); - //$this->mySQLaccess = e107::getDb()->get_mySQLaccess(); + $success = $this->connect($this->mySQLserver, $this->mySQLuser, $this->mySQLpassword); + if ($success) $success = $this->database($this->mySQLdefaultdb, $this->mySQLPrefix); + if (!$success) throw new PDOException($this->mySQLlastErrText); } }