]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17374 DML: improved BC in pg driver
authorskodak <skodak>
Mon, 24 Nov 2008 07:38:07 +0000 (07:38 +0000)
committerskodak <skodak>
Mon, 24 Nov 2008 07:38:07 +0000 (07:38 +0000)
lib/dml/pgsql_native_moodle_database.php

index d110c74eb4cba8178882cc4e5e46337fa89c6241..6aaef062ff31817bb0618a45a495fd97e7189fd2 100644 (file)
@@ -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();