i在脚本下编写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=";或任何阿拉伯文字
CDb命令未能执行SQL语句:SQLSTATE[HY000]:一般错误:1267操作"="的排序规则(latin1_swidish_ci,IMPLICIT)和(utf8_General_ci,COERCIBLE)的非法混合。执行的SQL语句为:SELECT*FROM useraccounts
t
WHERE t
。username
=:yp0极限1
请帮我
您的useraccounts
表的编码和排序似乎不适合与YII应用程序的UTF-8输入进行比较。尝试将表的字符集更改为utf8
,并按如下所示排序规则utf8_general_ci
:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;