I use mysql5 and utf8 table to store Chinese data. Everything
insert into the utf8 tables though cake can be fetch out by cake fine.
But when I use other database tools (such as MySQL Query Browser) to
query the data which insert by cake will got unreadable characters. I'm
so confuse on it, and serach on the internet. I think there is
something wrong with the mysql connections setting in cake.
    In my controller  I query the MySQL connection setting by  do this

...
$msg = $this->MyModel->findBySql("Show VARIABLES LIKE
'%CHARACTER_SET%';");
// Then set the result varable $msg to display in views
$this->set('msg',$msg);
....

In view:
...
debug($msg);
...

Then I got this result:
Array
(
    [0] => Array
        (
            [VARIABLES] => Array
                (
                    [Variable_name] => character_set_client
                    [Value] => latin1
                )

        )

    [1] => Array
        (
            [VARIABLES] => Array
                (
                    [Variable_name] => character_set_connection
                    [Value] => latin1
                )

        )

    [2] => Array
        (
            [VARIABLES] => Array
                (
                    [Variable_name] => character_set_database
                    [Value] => utf8
                )

        )

    [3] => Array
        (
            [VARIABLES] => Array
                (
                    [Variable_name] => character_set_results
                    [Value] => latin1
                )

        )

    [4] => Array
        (
            [VARIABLES] => Array
                (
                    [Variable_name] => character_set_server
                    [Value] => utf8
                )

        )

    [5] => Array
        (
            [VARIABLES] => Array
                (
                    [Variable_name] => character_set_system
                    [Value] => utf8
                )

        )

    [6] => Array
        (
            [VARIABLES] => Array
                (
                    [Variable_name] => character_sets_dir
                    [Value] => D:\Program Files\MySQL\MySQL Server
5.0\share\charsets\
                )

        )

)

The character_set_client,character_set_results,character_set_connection
is Laten1, and the other is utf8. I think the problem is here. So I
continue the test:

When I query the data in the utf8 table by convert the field to laten1
encoding, I can get the right chinese string. The SQL is:
SELECT CONVERT(myField USING utf8) from myUtf8Table;

How can I change the database connection setting to solve this problem?
Should I modify the core code?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to