开发者

UTF8 Encoding not working within CakePHP Shell

I have a CakePHP site that is working fine (in terms of encoding)...but a shell script is not encoding data correctly when saving data. The website and shell are using the same connection string...but the UTF8 encoding is not be respected by the shell program. (1 odd thing to note: if I r开发者_开发技巧emove the 'encoding' element from the connection string and run the shell program is saves the data as expected...but I would like to re-use the same connection string).

mysql database:

CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci

cakephp mysql connection string:

var $default = array(
    'driver' => 'mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'user',
    'password' => 'mypassword',
    'database' => 'dbname',
    'prefix' => '',
            'encoding' => 'utf8'
);


in your shell script, try running the following query immediately after the connection:

SET NAMES 'utf8'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜