summaryrefslogtreecommitdiff
path: root/program/lib
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-05-29 19:36:33 +0200
committerAleksander Machniak <alec@alec.pl>2013-05-29 19:38:41 +0200
commit983308e8b364c0ae5358874087977df9740d97ac (patch)
treef0d3d90aef272210d6e3a156d135e2399acbd0bd /program/lib
parent7b81cdb8e341c438062eb9b73f2ff273175c15b3 (diff)
Fix connection to posgtres db using unix socket (#1489132)
Conflicts: CHANGELOG
Diffstat (limited to 'program/lib')
-rw-r--r--program/lib/Roundcube/rcube_db_pgsql.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/program/lib/Roundcube/rcube_db_pgsql.php b/program/lib/Roundcube/rcube_db_pgsql.php
index cf23c5e48..a06a37c10 100644
--- a/program/lib/Roundcube/rcube_db_pgsql.php
+++ b/program/lib/Roundcube/rcube_db_pgsql.php
@@ -129,4 +129,38 @@ class rcube_db_pgsql extends rcube_db
return isset($this->variables[$varname]) ? $this->variables[$varname] : $default;
}
+ /**
+ * Returns PDO DSN string from DSN array
+ *
+ * @param array $dsn DSN parameters
+ *
+ * @return string DSN string
+ */
+ protected function dsn_string($dsn)
+ {
+ $params = array();
+ $result = 'pgsql:';
+
+ if ($dsn['hostspec']) {
+ $params[] = 'host=' . $dsn['hostspec'];
+ }
+ else if ($dsn['socket']) {
+ $params[] = 'host=' . $dsn['socket'];
+ }
+
+ if ($dsn['port']) {
+ $params[] = 'port=' . $dsn['port'];
+ }
+
+ if ($dsn['database']) {
+ $params[] = 'dbname=' . $dsn['database'];
+ }
+
+ if (!empty($params)) {
+ $result .= implode(';', $params);
+ }
+
+ return $result;
+ }
+
}