mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-29 20:30:54 +00:00
Mask database connection error
This commit is contained in:
parent
6bd1563f9b
commit
4e4052a3df
1 changed files with 6 additions and 5 deletions
|
@ -65,21 +65,22 @@ class DBLayer {
|
|||
} else {
|
||||
$dsn = "mysql:";
|
||||
$dsn .= "host=" . $cfg['db'][$db]['host'] . ";";
|
||||
$dsn .= "dbname=" . $cfg['db'][$db]['name'] . ";"; // Comment this out when using the cache
|
||||
// $dsn .= "dbname=" . $cfg['db'][$db]['name'] . ";"; // Comment this out when using the cache
|
||||
$dsn .= "port=" . $cfg['db'][$db]['port'] . ";";
|
||||
|
||||
$opt = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
// PDO::ATTR_PERSISTENT => true,
|
||||
PDO::ATTR_TIMEOUT => 5
|
||||
);
|
||||
$PDOCache[$this->host] = array();
|
||||
try {
|
||||
$this->PDO = new PDO($dsn, $cfg['db'][$db]['user'], $cfg['db'][$db]['pass'], $opt);
|
||||
} catch (Exception $e) {
|
||||
$PDOCache[$this->host]['exception'] = $e;
|
||||
throw $e;
|
||||
} catch (PDOException $e) {
|
||||
$exception = new PDOException("Failed to connect to the '" . $db . "' database server", $e->getCode());
|
||||
$PDOCache[$this->host]['exception'] = $exception;
|
||||
throw $exception;
|
||||
return;
|
||||
}
|
||||
$PDOCache[$this->host]['pdo'] = $this->PDO;
|
||||
|
|
Loading…
Reference in a new issue