pdo_connect: catch exception on create

This commit is contained in:
Andrew Dolgov 2017-12-10 09:27:07 +03:00
parent f8db5bb4db
commit 83a052f1fa
1 changed files with 6 additions and 6 deletions

View File

@ -54,12 +54,12 @@ class Db
$db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : '';
$db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : '';
try {
$this->pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port,
DB_USER,
DB_PASS);
if (!$this->pdo) {
print("Error connecting via PDO.");
} catch (Exception $e) {
print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>";
exit(101);
}