我现在仍在学习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)=。WHy需要?,这是我还不知道的查询条件吗?https://stackoverflow.com/questions/7567686
复制相似问题