我现在仍在博客教程上学习 YII,并对一些代码感到好奇。
在这个链接
http://www.yiiframework.com/doc/blog/1.1/en/prototype.auth
有这样的代码
<?php
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$username=strtolower($this->username);
$user=User::model()->find('LOWER(username)=?',array($username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}
public function getId()
{
return $this->_id;
}
}
我对一些代码感到好奇。
?>
为什么代码的最后一行没有?- 在这一行为什么不
$user=User::model()->find('LOWER(username)=?',array($username));
使用。为什么需要,这是一些我还不知道的条件查询吗?LOWER(username)=?
LOWER(username)=
?