本文整理汇总了PHP中MemberModel::model方法的典型用法代码示例。如果您正苦于以下问题:PHP MemberModel::model方法的具体用法?PHP MemberModel::model怎么用?PHP MemberModel::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberModel
的用法示例。
在下文中一共展示了MemberModel::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$user_info = MemberModel::model()->find("username=:username", array(":username" => $this->username));
if ($user_info) {
if ($user_info['pswd'] != md5($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->errorCode = self::ERROR_NONE;
}
} else {
$this->errorCode = self::ERROR_USERNAME_INVALID;
}
return !$this->errorCode;
}
示例2: beforeAction
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
if (Yii::app()->user->isGuest) {
$this->redirect(array('site/login'));
} else {
$userInfo = MemberModel::model()->find('username=:username', array(':username' => Yii::app()->user->name));
foreach (GroupModel::model()->findAll() as $g) {
$group[$g->id] = $g;
}
Yii::app()->session['group'] = $group;
Yii::app()->session['userInfo'] = array('uid' => $userInfo->uid, 'username' => $userInfo->username, 'nickname' => $userInfo->nickname, 'lv' => $userInfo->lv, 'groupId' => $userInfo->groupId);
}
}
return true;
}