Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Request #14794 UTF8 Support for MYSQL database
Submitted: 2008-10-14 14:01 UTC
From: repher Assigned:
Status: Open Package: DB_DataObject (version 1.8.8)
PHP Version: 5.2.6 OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 20 - 12 = ?

 
 [2008-10-14 14:01 UTC] repher (Bernhard)
Description: ------------ Mysql does not use utf8 by default. Since i almost never use anything else than utf8, i have to modify the DB_DataObject class everytime to execute a 'set names utf8' query at the end of the _connect function. Maybe we should consider implementing a feature to check if there is for example a 'mysql_client_encoding' option in the options. I have implemented a simple addition to _connect to solve this problem: if (isset($_DB_DATAOBJECT['CONFIG']['mysql_client_encoding'])) { if ($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]- >dsn['phptype'] == 'mysqli') { $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]- >query("SET NAMES " . $_DB_DATAOBJECT['CONFIG']['mysql_client_encoding'] ); } }

Comments

 [2012-11-27 23:01 UTC] shankao (shankao asdasd)
Once your mysql server is configured to use utf8 (this is a server config problem, no dataobject), just change the connection charset in the dsn: $dsn = "mysql://user:password@host/dbname?charset=utf8"; That removes the need for an extra query() call. P.D.: but support for a more elegant option to specify the charset would be nice to have directly implemented in DataObject.