--- environment.inc~	2009-04-16 04:35:43.000000000 +0200
+++ environment.inc	2009-04-25 04:05:19.000000000 +0200
@@ -475,6 +475,7 @@
          $creds['user'] = $parts['user'];
          $creds['host'] = $parts['host'];
          $creds['pass'] = $parts['pass'];
+         $creds['port'] = $parts['port'];
          $creds['name'] = trim($parts['path'], '/');
        }
        break;
@@ -485,6 +486,7 @@
          $creds['user'] = $conn['username'];
          $creds['host'] = $conn['host'];
          $creds['name'] = $conn['database'];
+         $creds['port'] = $parts['port'];
          $creds['pass'] = $conn['password'];
        }
        break;
@@ -686,6 +688,9 @@
     }
 
     $constr = sprintf("%s:dbname=%s;host=%s", $type, $creds['name'], $creds['host']);
+    if (isset($creds['port'])) {
+      $constr .= sprintf(";port=%d", $creds['port']);
+    }
     
     try {
       $db = new PDO($constr, $creds['user'], $creds['pass']);
