Req #14794 [Com]: UTF8 Support for MYSQL database

From: Date: Tue, 27 Nov 2012 18:02:15 +0000
Subject: Req #14794 [Com]: UTF8 Support for MYSQL database
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-9377@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=14794&edit=1 ID: 14794 Comment by: shankao Reported By: shankao at gmail dot com Summary: UTF8 Support for MYSQL database Status: Open Type: Feature/Change Request Package: DB_DataObject Operating System: irrelevant Package Version: 1.8.8 PHP Version: 5.2.6 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2008-10-14 10:01:25] repher 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'] ); } } ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=14794&edit=1

« previous php.pear.bugs (#9377) next »