2009年1月22日星期四

Re: [fw-db] Encoding problems

Hi,

If I use a utf-8 MySQL database and utf8 encoded output on website, I
don't think I need to call SET NAMES explicitly, but I do not think it
will harm if you do.

But you should check if you output the result from the database in an
utf8 environment, for example a web page that uses utf8 as the encoding
type.

Not sure if this will help.

-Bart

Lossoth schreef:
> Hello,
>
> I'm developing a web-app using PostgreSQL and Zend_Db.
> The database is encoded in UTF8.
> If in a field I've a character with accent (like: à ò è ù), in the DB it is
> show correctly.
> A fetcAll() on this table returns the characters with accent on a wrong way.
> My problem is wery similar to this thread "How to specify Charset with
> PDO/MySQL":
> http://www.nabble.com/How-to-specify-Charset-with-PDO-MySQL-tt7438169.html
>
> I've try the solution suggested in the thread but the problem persist.
>
> Someone can help me?
>
> My code:
>
> class Fx_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Pgsql {
> protected function _connect() {
> if ($this->_connection)
> return;
>
> parent::_connect();
>
> $this->query("SET NAMES 'UTF8'");
> }
> }
>
>
> $db = new Fx_Db_Adapter_Pdo_Pgsql(array(
> 'host' => 'localhost',
> 'username' => '******',
> 'password' => '******',
> 'dbname' => 'dbname'
> ));
>
> Zend_Db_Table_Abstract::setDefaultAdapter($db);
>
>

没有评论: