首页 文章

PHP Yii:在登录时输入阿拉伯语文本到用户名字段显示错误CDbException

提问于
浏览
1

我在脚本下编写UserIdentity方法authenticate():

$user =  UserAccounts::model()->findByAttributes(array('username'=>$this->username));

    if($user === null)
        $this->errorCode=self::ERROR_USERNAME_INVALID;
    elseif($user->password!==$this->password)
        $this->errorCode=self::ERROR_PASSWORD_INVALID;
    else
        $this->errorCode=self::ERROR_NONE;

    return !$this->errorCode;

但存在一个警告问题:当我输入阿拉伯语到文本框用户名字段时显示错误:

例如username ='شسیششب';或任何文本阿拉伯语

CDbCommand 无法执行SQL语句:SQLSTATE [HY000]:常规错误:1267操作'='非法混合归类(latin1_swedish_ci,IMPLICIT)和(utf8_general_ci,COERCIBLE) . 执行的SQL语句是:SELECT * FROM useraccounts t WHERE t . username =:yp0 LIMIT 1

请帮我

1 回答

  • 2

    您的 useraccounts 表的编码和排序规则似乎不适合与YII应用程序的UTF-8输入进行比较 . 尝试将表的字符集更改为 utf8 ,并将整理 utf8_general_ci 更改为it shown here

    ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
    

相关问题