summaryrefslogtreecommitdiff
path: root/includes/database/pgsql
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-12-25 00:40:22 -0800
committerwebchick <webchick@24967.no-reply.drupal.org>2011-12-25 00:40:22 -0800
commit2f6d917af5b7367e2956a16f76909ac09110b853 (patch)
tree8f42e2fd426e36e7912287bc025e30e67aa41581 /includes/database/pgsql
parent15e66edf06ff2fa366e21c192fdfe5e35ca52f6e (diff)
downloadbrdo-2f6d917af5b7367e2956a16f76909ac09110b853.tar.gz
brdo-2f6d917af5b7367e2956a16f76909ac09110b853.tar.bz2
Issue #1309278 by basic, Niklas Fiekas: Added Make PDO connection options configurable.
Diffstat (limited to 'includes/database/pgsql')
-rw-r--r--includes/database/pgsql/database.inc15
1 files changed, 13 insertions, 2 deletions
diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc
index 39b4e9b69..d42a1cc3c 100644
--- a/includes/database/pgsql/database.inc
+++ b/includes/database/pgsql/database.inc
@@ -47,7 +47,12 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
$this->connectionOptions = $connection_options;
$dsn = 'pgsql:host=' . $connection_options['host'] . ' dbname=' . $connection_options['database'] . ' port=' . $connection_options['port'];
- parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array(
+
+ // Allow PDO options to be overridden.
+ $connection_options += array(
+ 'pdo' => array(),
+ );
+ $connection_options['pdo'] += array(
// Prepared statements are most effective for performance when queries
// are recycled (used several times). However, if they are not re-used,
// prepared statements become ineffecient. Since most of Drupal's
@@ -59,10 +64,16 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
PDO::ATTR_STRINGIFY_FETCHES => TRUE,
// Force column names to lower case.
PDO::ATTR_CASE => PDO::CASE_LOWER,
- ));
+ );
+ parent::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
// Force PostgreSQL to use the UTF-8 character set by default.
$this->exec("SET NAMES 'UTF8'");
+
+ // Execute PostgreSQL init_commands.
+ if (isset($connection_options['init_commands'])) {
+ $this->exec(implode('; ', $connection_options['init_commands']));
+ }
}
public function query($query, array $args = array(), $options = array()) {