Re: Re: PDO don't know which is mysql server charset?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cleverpig wrote:
> But if I use PDO's query function,there is all right without set charset:
> $result=$myPDO->query("SELECT * FROM guests ORDER BY lname,fname");
> while($row=$result->fetch(PDO::FETCH_ASSOC)){
> 	echo $row["fname"]." ". $row["lname"];
> }
> 
>> I encountered a problem using the PDO:
>> My mysql charset is utf-8, when using PDO's prepare () and statement's
>> execute() methods,
>> there is not the correct encoding resultset:
>> $ Statement = $ pdo->  prepare ("SELECT * FROM guests ORDER BY?");
>> $ Statement->  execute (array ('lname'));
>> while ($ row = $ statement->  fetch (PDO:: FETCH_ASSOC)) (
>>     echo $ row ['fname']. "". $ row ['lname'];
>> )
>>
>> But when I was make charset_set_results to be gbk, everything was normal:
>> $ Pdo->  exec ('SET character_set_results = gbk');
>>
>> If PDO don't know which charset is fit to me,it will use default
>> charset(utf-8)?This is really mysql server charset!

The tikiwiki project has just picked up on this problem, and it may be that you
are missing a key piece of information! What THEY are finding is that while the
data is being displayed correctly, what is stored in the database is ACTUALLY
'double encoded'. So as long as you 'double decode' it things are OK, but the
data stored in MySQL is actually corrupt and unreadable by other applications!

What they are currently trying to work out is how to process damaged databases
in addition to sorting out how the connection should be set up.
http://dev.tikiwiki.org/UTF-8+Testcase has more information ....

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux