From edeb5d7ab42a714a10a5468ef51fcca589bbbba7 Mon Sep 17 00:00:00 2001 From: laodc Date: Tue, 30 Jan 2018 13:51:54 +0700 Subject: [PATCH] Add support for PostgreSQL schemas in DSN (#6150) If schema is set in the dsn, set search_path to the schema value. Example: $config['db_dsnw'] = 'pgsql://user:pass@localhost/dbname?schema=exampleschema'; --- program/lib/Roundcube/rcube_db_pgsql.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/program/lib/Roundcube/rcube_db_pgsql.php b/program/lib/Roundcube/rcube_db_pgsql.php index 12ad7f1f8..290c8a3e8 100644 --- a/program/lib/Roundcube/rcube_db_pgsql.php +++ b/program/lib/Roundcube/rcube_db_pgsql.php @@ -56,6 +56,11 @@ class rcube_db_pgsql extends rcube_db { $dbh->query("SET NAMES 'utf8'"); $dbh->query("SET DATESTYLE TO ISO"); + + // if ?schema= is set in dsn, set the search_path + if ($dsn['schema']) { + $dbh->query("SET search_path TO " . $this->quote($dsn['schema'])); + } } /**