Re: Db_DataObject - how to force connection to be utf8?

From: Date: Tue, 09 Aug 2005 23:58:38 +0000
Subject: Re: Db_DataObject - how to force connection to be utf8?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20343@lists.php.net to get a copy of this message
On 8/9/05, Paul Groves <paul.groves@computing-services.oxford.ac.uk> wrote: > Hi I'm using Db_DataObject (latest version) for a project (along with > PHP 5.03 and MySQl 4.1) and the database tables (which of course map to > Db_DataObject objects) I'm using are all in unicode (i.e.utf8) and > currently some characters (e.g. curly quotes) being read from the > database fields are not being displayed correctly on the web page, > though the web page is set to display utf8 (and the browser recognises > this). I'm presuming this is because the database *connection* also > needs to set to utf8 - normally I would just do this using an SQL > command after making the connection, i.e. > > SET NAMES 'utf8'; > > However, I can't see how this is possible using DB_DataObject, since the > whle database connection thing is abstracted out. I thought there might > be a Db_Database configuration option to set the character set for the > connection, but there doesn't appear to be one. Does anyone have any > tips for how to force the connection to be utf-8 when using > Db_DataObject? Try doing this at the beginning of your application: $do = DB_DataObject::factory('tableNameHere'); $do->query('SET NAMES "utf8"'); -- Justin Patrin

« previous php.pear.general (#20343) next »