1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 04:40:44 +02:00

e_db_pdo: Throw exception instead of fatal erroring on connect fail

Now e_db_pdo failures to connect to the database are catchable
This commit is contained in:
Nick Liu
2020-05-26 18:55:47 -05:00
parent b074ad21b0
commit 339765bf0e
2 changed files with 4 additions and 12 deletions

View File

@@ -1363,7 +1363,7 @@ class e107
* $instance_id * $instance_id
* *
* @param string $instance_id * @param string $instance_id
* @return e_db_mysql * @return e_db
*/ */
public static function getDb($instance_id = '') public static function getDb($instance_id = '')
{ {

View File

@@ -2808,19 +2808,11 @@ class e_db_pdo implements e_db
*/ */
private function _getMySQLaccess() private function _getMySQLaccess()
{ {
/*if (!$this->mySQLaccess) {
global $db_ConnectionID;
$this->mySQLaccess = $db_ConnectionID;
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2);
}*/
if (!$this->mySQLaccess) if (!$this->mySQLaccess)
{ {
// debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2); $success = $this->connect($this->mySQLserver, $this->mySQLuser, $this->mySQLpassword);
$this->connect($this->mySQLserver, $this->mySQLuser, $this->mySQLpassword); if ($success) $success = $this->database($this->mySQLdefaultdb, $this->mySQLPrefix);
$this->database($this->mySQLdefaultdb, $this->mySQLPrefix); if (!$success) throw new PDOException($this->mySQLlastErrText);
//$this->mySQLaccess = e107::getDb()->get_mySQLaccess();
} }
} }