Gus*_*ooL 2 php yii yii-cactiverecord
我现在仍然在博客教程上学习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;
}
}
Run Code Online (Sandbox Code Playgroud)
我对一些代码很好奇.
?>代码的最后一行没有?$user=User::model()->find('LOWER(username)=?',array($username));为什么用LOWER(username)=?不LOWER(username)=.为什么有需要?,是否有一些查询有条件我可能还不知道呢?