2013-10-24 15:55:20 2968次浏览 1条回答 0 悬赏 10 金钱

在YII框架中,我们建立查询语句如下:

$model=  User::model()->find("username=:username",array(":username"=>$this->username));

如果$username为中文,系统将会报错,请问这个怎么解决。

  • 回答于 2013-10-24 16:32 举报

    啥错呢?

    3 条回复
    回复于 2013-10-24 19:45 回复

    CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='. The SQL statement executed was: SELECT * FROM tbl_user t WHERE username=:username LIMIT 1

    回复于 2013-10-24 19:46 回复

    应该是中文无法检索吧。
    这个问题怎么解决呢?

    回复于 2013-10-26 15:12 回复

    问题解决了,是数据库的编码设置错误了。

您需要登录后才可以回答。登录 | 立即注册
FOOKLOOK
职场新人

FOOKLOOK

注册时间:2013-10-03
最后登录:2013-11-03
在线时长:7小时0分
  • 粉丝0
  • 金钱20
  • 威望0
  • 积分90

热门问题