From f22ceb42c25af89f768469a43bb8dce055cda9be Mon Sep 17 00:00:00 2001 From: Paul Arthur Date: Mon, 13 May 2013 17:33:12 -0400 Subject: Add support for nonstandard MySQL ports --- lib/class/dba.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/class') 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); -- cgit