Mask database connection error

hg/feature/cdb-packed
kaetemi 10 years ago
parent 7cd21d48b4
commit d863ed8a10

@ -65,21 +65,22 @@ class DBLayer {
} else { } else {
$dsn = "mysql:"; $dsn = "mysql:";
$dsn .= "host=" . $cfg['db'][$db]['host'] . ";"; $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'] . ";"; $dsn .= "port=" . $cfg['db'][$db]['port'] . ";";
$opt = array( $opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_PERSISTENT => true, // PDO::ATTR_PERSISTENT => true,
PDO::ATTR_TIMEOUT => 5 PDO::ATTR_TIMEOUT => 5
); );
$PDOCache[$this->host] = array(); $PDOCache[$this->host] = array();
try { try {
$this->PDO = new PDO($dsn, $cfg['db'][$db]['user'], $cfg['db'][$db]['pass'], $opt); $this->PDO = new PDO($dsn, $cfg['db'][$db]['user'], $cfg['db'][$db]['pass'], $opt);
} catch (Exception $e) { } catch (PDOException $e) {
$PDOCache[$this->host]['exception'] = $e; $exception = new PDOException("Failed to connect to the '" . $db . "' database server", $e->getCode());
throw $e; $PDOCache[$this->host]['exception'] = $exception;
throw $exception;
return; return;
} }
$PDOCache[$this->host]['pdo'] = $this->PDO; $PDOCache[$this->host]['pdo'] = $this->PDO;

Loading…
Cancel
Save