From 000c881e98643e298d245d90ef55f6ce37462b2c Mon Sep 17 00:00:00 2001 From: Aparup Banerjee Date: Thu, 9 Dec 2010 07:01:03 +0000 Subject: [PATCH] lib MDL-25595 added dbport option handling to mssql connect() --- lib/dml/mssql_native_moodle_database.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/dml/mssql_native_moodle_database.php b/lib/dml/mssql_native_moodle_database.php index f1aaf11ec7e..be9fdb10e35 100644 --- a/lib/dml/mssql_native_moodle_database.php +++ b/lib/dml/mssql_native_moodle_database.php @@ -138,11 +138,19 @@ class mssql_native_moodle_database extends moodle_database { $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions); + $dbhost = $this->dbhost; + if (isset($dboptions['dbport'])) { + if (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) { + $dbhost .= ','.$dboptions['dbport']; + } else { + $dbhost .= ':'.$dboptions['dbport']; + } + } ob_start(); if (!empty($this->dboptions['dbpersist'])) { // persistent connection - $this->mssql = mssql_pconnect($this->dbhost, $this->dbuser, $this->dbpass, true); + $this->mssql = mssql_pconnect($dbhost, $this->dbuser, $this->dbpass, true); } else { - $this->mssql = mssql_connect($this->dbhost, $this->dbuser, $this->dbpass, true); + $this->mssql = mssql_connect($dbhost, $this->dbuser, $this->dbpass, true); } $dberr = ob_get_contents(); ob_end_clean();