I'm using Zend_DB and trying to change the charset to utf8, here is the code:
config.ini :
[development]
db.host = "localhost"
db.username = "root"
db.password = "toor"
db.dbname = "db_whoopdiedo"
db.charset = "utf8"
bootstrap.php :
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function _initAutoload()
{
Zend_Registry::set(
'config',
new Zend_Config_Ini(APPLICATION_PATH.'/configs/config.ini', 'development')
);
Zend_Registry::set(
'db',
Zend_Db::factory('Pdo_Mysql', Zend_Registry::get('config')->db)
);
Zend_Registry::get('db')->setFetchMode(Zend_Db::FETCH_OBJ);
Zend_Registry::get('db')->query("SET NAMES 'utf8'");
Zend_Registry::get('db')->query("SET CHARACTER SET 'utf8'");
}
}
i thought it would be enough to add the charset in the config, but he only applys it if i set it directly using:
Zend_Registry::get('db')->query("SET NAMES 'utf8'");
Zend_Registry::get('db')->query("SET CHARACTER SET 'utf8'");
My Question: is there a better way to set the charset, maybe config wise?