summaryrefslogtreecommitdiff
path: root/classes/db.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-12-10 09:27:07 +0300
committerAndrew Dolgov <[email protected]>2017-12-10 09:27:07 +0300
commit83a052f1fa36e6bcebc6b6ee1ba6cfc9d9f480d0 (patch)
treec714a6714b9524daf4e86c6e43d7142b830c4c12 /classes/db.php
parentf8db5bb4db45f7e867a7f1e29ef58e1fd1473edc (diff)
pdo_connect: catch exception on create
Diffstat (limited to 'classes/db.php')
-rw-r--r--classes/db.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/classes/db.php b/classes/db.php
index b6320944b..96a888275 100644
--- a/classes/db.php
+++ b/classes/db.php
@@ -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 : '';
- $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.");
+ try {
+ $this->pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port,
+ DB_USER,
+ DB_PASS);
+ } catch (Exception $e) {
+ print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>";
exit(101);
}