summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-05-13 17:33:12 -0400
committerPaul Arthur <paul.arthur@flowerysong.com>2013-05-13 17:33:12 -0400
commitf22ceb42c25af89f768469a43bb8dce055cda9be (patch)
tree66b64663eec1d1e950ce90982a7de3912f94b4e2 /lib
parent6bed09fbc9e5b18a925e48c7fc41f9ca29055c47 (diff)
downloadampache-f22ceb42c25af89f768469a43bb8dce055cda9be.tar.gz
ampache-f22ceb42c25af89f768469a43bb8dce055cda9be.tar.bz2
ampache-f22ceb42c25af89f768469a43bb8dce055cda9be.zip
Add support for nonstandard MySQL ports
Diffstat (limited to 'lib')
-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);