Re: DB/DB_DataObject and MySQL character sets

From: Date: Tue, 14 Dec 2004 17:13:29 +0000
Subject: Re: DB/DB_DataObject and MySQL character sets
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16230@lists.php.net to get a copy of this message
On Tue, 14 Dec 2004 12:23:53 +0300, Denis Gerasimov <denis.gerasimov@vekos.ru> wrote: > > Hello, > > I use DB/DB_DataObject (latest versions) + MySQL 4.1.7 > > Almost every query to db fails with this message: > > [DB_Error: message="DB Error: unknown error" code=-1 mode=return > level=notice prefix="" info="SELECT * FROM news_news WHERE status = > 'PUBLISHED' ORDER BY date DESC LIMIT 8 [nativecode=1267 ** Illegal mix of > collations (cp1251_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) > for operation '=']"] > > MySQL default character set is cp1251, table data is stored in cp1251 > codepage too. > > AFAIK that may be fixed using the following query: > > SET CHARACTER SET cp1251 > > but it should be run immediately after establishing connection to MySQL > server. > > Is there a way to set the codepage (charater set) in DB_DataObject or, at > least, run this query first of all (I don't mean writing this query every > time after DB_DO instantiation of course)? > > Maybe sombody knows how to make cp1251 default _connection_ charset in > MySQL, if so, please drop me a note. I tried: > > default-character-set=cp1251 > > in my.ini, but it didn't help me. > Here's a quick hac for you. After including your ini file, get a DO and set the charset. $do = DB_DataObject::factory('someTable'); $do->query('SET CHARACTER SET cp1251'); -- Justin Patrin

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