From e6b854a01cfcf915947480f96744b599d5e20952 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 24 Nov 2008 07:38:07 +0000 Subject: [PATCH] MDL-17374 DML: improved BC in pg driver --- lib/dml/pgsql_native_moodle_database.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/dml/pgsql_native_moodle_database.php b/lib/dml/pgsql_native_moodle_database.php index d110c74eb4..6aaef062ff 100644 --- a/lib/dml/pgsql_native_moodle_database.php +++ b/lib/dml/pgsql_native_moodle_database.php @@ -97,15 +97,18 @@ class pgsql_native_moodle_database extends moodle_database { $pass = addcslashes($this->dbpass, "'\\"); // Unix socket connections should have lower overhead - if (empty($this->dboptions['forcetcp']) and ($this->dbhost === 'localhost' or $this->dbhost === '127.0.0.1')) { + if (!empty($this->dboptions['dbsocket']) and ($this->dbhost === 'localhost' or $this->dbhost === '127.0.0.1')) { $connection = "user='$this->dbuser' password='$pass' dbname='$this->dbname'"; } else { - if (empty($this->dboptions['dbport'])) { - $port = 5432; + if (empty($this->dbname)) { + // probably old style socket connection - do not add port + $port = ""; + } else if (empty($this->dboptions['dbport'])) { + $port = "port ='5432'"; } else { - $port = $this->dboptions['dbport']; + $port = "port ='".$this->dboptions['dbport']."'"; } - $connection = "host='$this->dbhost' port='$port' user='$this->dbuser' password='$pass' dbname='$this->dbname'"; + $connection = "host='$this->dbhost' $port user='$this->dbuser' password='$pass' dbname='$this->dbname'"; } ob_start(); -- 2.39.5