Support and fix setting the client/connection charset for PostgreSQL with the standar...
authorJan Schneider <jan@horde.org>
Mon, 17 Jan 2011 17:12:20 +0000 (18:12 +0100)
committerJan Schneider <jan@horde.org>
Mon, 17 Jan 2011 17:15:59 +0000 (18:15 +0100)
framework/Db/lib/Horde/Db/Adapter/Pdo/Pgsql.php
framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php

index 0fa2e4a..e0d83ac 100644 (file)
@@ -215,9 +215,9 @@ class Horde_Db_Adapter_Pdo_Pgsql extends Horde_Db_Adapter_Pdo_Base
      */
     protected function _configureConnection()
     {
-        if (!empty($this->_config['encoding'])) {
-            $this->last_query = 'SET client_encoding TO '.$this->quoteString($this->_config['encoding']);
-            $this->_connection->execute($this->last_query);
+        if (!empty($this->_config['charset'])) {
+            $this->last_query = 'SET client_encoding TO '.$this->quoteString($this->_config['charset']);
+            $this->execute($this->last_query);
         }
 
         if (!empty($this->_config['client_min_messages'])) $this->setClientMinMessages($this->_config['client_min_messages']);
index e819fee..5c8b8d3 100644 (file)
@@ -140,17 +140,14 @@ class Horde_Db_Adapter_Postgresql_Schema extends Horde_Db_Adapter_Base_Schema
     }
 
     /**
-     * Create a new PostgreSQL database.  Options include <tt>:owner</tt>, <tt>:template</tt>,
-     * <tt>:encoding</tt>, <tt>:tablespace</tt>, and <tt>:connection_limit</tt> (note that MySQL uses
-     * <tt>:charset</tt> while PostgreSQL uses <tt>:encoding</tt>).
+     * Creates a new PostgreSQL database.
      *
-     * Example:
-     *   create_database config[:database], config
-     *   create_database 'foo_development', :encoding => 'unicode'
+     * Options include: owner, template, charset, tablespace, and
+     * connection_limit.
      */
     public function createDatabase($name, $options = array())
     {
-        $options = array_merge(array('encoding' => 'utf8'), $options);
+        $options = array_merge(array('charset' => 'utf8'), $options);
 
         $optionString = '';
         foreach ($options as $key => $value) {
@@ -161,7 +158,7 @@ class Horde_Db_Adapter_Postgresql_Schema extends Horde_Db_Adapter_Base_Schema
             case 'template':
                 $optionString .= " TEMPLATE = $value";
                 break;
-            case 'encoding':
+            case 'charset':
                 $optionString .= " ENCODING = '$value'";
                 break;
             case 'tablespace':