summaryrefslogtreecommitdiffstats
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
parent6bed09fbc9e5b18a925e48c7fc41f9ca29055c47 (diff)
downloadampache-f22ceb42c25af89f768469a43bb8dce055cda9be.tar.gz
ampache-f22ceb42c25af89f768469a43bb8dce055cda9be.tar.bz2
ampache-f22ceb42c25af89f768469a43bb8dce055cda9be.zip
Add support for nonstandard MySQL ports
-rw-r--r--config/ampache.cfg.php.dist6
-rwxr-xr-xdocs/CHANGELOG.md1
-rw-r--r--lib/class/dba.class.php9
3 files changed, 14 insertions, 2 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index ac9b6dc2..ff05b6f5 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -26,10 +26,14 @@ config_version = 12
; Session and Login Variables #
;##############################
-; Hostname of your Database
+; Hostname of your database
; DEFAULT: localhost
database_hostname = localhost
+; Port to use when connecting to your database
+; DEFAULT: none
+; database_port = 3306
+
; Name of your ampache database
; DEFAULT: ampache
database_name = ampache
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index f4dd5eb4..9aaf117b 100755
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -3,6 +3,7 @@ CHANGELOG
3.6-FUTURE
----------
+- Added support for nonstandard database ports
- Updated getID3 to 1.9.5
- Improved the performance of stream playlist creation (reported by AkbarSerad)
- Fixed "Pure Random" / Random URLs (reported by mafe)
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);