From 8897ba06f7b959db228aaf8b7d7ec5d50a11ae70 Mon Sep 17 00:00:00 2001 From: tof <> Date: Fri, 18 Apr 2008 13:12:19 +0000 Subject: Fixed #833 --- framework/Data/TDbConnection.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'framework/Data') diff --git a/framework/Data/TDbConnection.php b/framework/Data/TDbConnection.php index 08a8695a..2f5a0358 100644 --- a/framework/Data/TDbConnection.php +++ b/framework/Data/TDbConnection.php @@ -27,7 +27,9 @@ Prado::using('System.Data.TDbCommand'); * specifying {@link setConnectionString ConnectionString}, {@link setUsername Username} * and {@link setPassword Password}. * - * Since 3.1.2, the connection charset can be set (for MySQL databases only) using the {@link setCharset Charset} property. + * Since 3.1.2, the connection charset can be set (for MySQL and PostgreSQL databases only) + * using the {@link setCharset Charset} property. The value of this property is database dependant. + * e.g. for mysql, you can use 'latin1' for cp1252 West European, 'utf8' for unicode, ... * * The following example shows how to create a TDbConnection instance and establish * the actual connection: @@ -100,7 +102,7 @@ class TDbConnection extends TComponent * @param string The Data Source Name, or DSN, contains the information required to connect to the database. * @param string The user name for the DSN string. * @param string The password for the DSN string. - * @param string Charset used for DB Connection (MySql only). If not set, will use the default charset of your database server + * @param string Charset used for DB Connection (MySql & pgsql only). If not set, will use the default charset of your database server * @see http://www.php.net/manual/en/function.PDO-construct.php */ public function __construct($dsn='',$username='',$password='', $charset='') @@ -200,9 +202,12 @@ class TDbConnection extends TComponent { case 'mysql': $stmt = $this->_pdo->prepare('SET CHARACTER SET ?'); - $stmt->execute(array($this->_charset)); + break; + case 'pgsql': + $stmt = $this->_pdo->prepare('SET client_encoding TO ?'); break; } + $stmt->execute(array($this->_charset)); } /** -- cgit v1.2.3