2
我現在仍然在博客教程上學習YII,並且對一些代碼感到好奇。YII CActiveRecord-> find()
此鏈接
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;
}
}
,我好奇的一些代碼。
- 爲什麼在代碼的最後一行沒有
?>
? - at this line
$user=User::model()->find('LOWER(username)=?',array($username));
why whyLOWER(username)=?
notLOWER(username)=
。爲什麼有需要?
,這是一些有條件的查詢條件,我還不知道呢?
謝謝droid :) – GusDeCooL