summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/dba.class.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php
index 8cbc6f55..f611751f 100644
--- a/lib/class/dba.class.php
+++ b/lib/class/dba.class.php
@@ -231,9 +231,16 @@ class Dba {
$username = Config::get('database_username');
$hostname = Config::get('database_hostname');
$password = Config::get('database_password');
+ $port = Config::get('database_port');
+
+ // Build the data source name
+ $dsn = 'mysql:host=' . $hostname ?: 'localhost';
+ if ($port) {
+ $dsn .= ';port=' . intval($port);
+ }
try {
- $dbh = new PDO('mysql:host=' . $hostname, $username, $password);
+ $dbh = new PDO($dsn, $username, $password);
}
catch (PDOException $e) {
debug_event('Dba', 'Connection failed: ' . $e->getMessage(), 1);