本文整理汇总了PHP中user::model方法的典型用法代码示例。如果您正苦于以下问题:PHP user::model方法的具体用法?PHP user::model怎么用?PHP user::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user
的用法示例。
在下文中一共展示了user::model方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionGetUsers
public function actionGetUsers()
{
$keyword = addslashes(trim($_GET['keyword']));
$condition = "1=1 ";
if ($keyword) {
$condition = $condition . " and name like '%{$keyword}%'";
}
if (isset($_GET['page_num']) && is_numeric($_GET['page_num'])) {
$page_num = intval($_GET['page_num']);
} else {
$page_num = 1;
}
if (isset($_GET['page_size']) && is_numeric($_GET['page_size'])) {
$page_size = intval($_GET['page_size']);
} else {
$page_size = 10;
}
$result = UserManager::findAll($page_num, $page_size, $condition);
//pagination
$criteria = new CDbCriteria();
$criteria->condition = $condition;
$records = user::model()->findAll($criteria);
$number = count($records);
$sum_page = ceil($number / $page_size);
$result = array('sum_page' => $sum_page, 'data' => $result, 'sum_count' => $number);
echo CJSON::encode($result);
}
示例2: actionIndex
public function actionIndex()
{
$access = parent::getAccess();
if (0 < $access) {
$this->ajaxReturn(array("login" => true, "formhash" => FORMHASH, "uid" => Yii::app()->user->uid, "user" => user::model()->fetchByUid(Yii::app()->user->uid)), "JSONP");
} else {
$this->ajaxReturn(array("login" => false, "msg" => "登录已超时,请重新登录"), "JSONP");
exit;
}
}
示例3: 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()
{
$userInfo = user::model()->find('username = :name', array(':name' => $this->username));
if ($userInfo == NULL) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
return false;
}
if ($userInfo['password'] != md5($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
return false;
}
$this->errorCode = self::ERROR_NONE;
return true;
}
示例4: 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 = user::model()->find('username=:username', array(':username' => $this->username));
if ($user == null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} elseif (!$user->validatePassword($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->_id = $user->id;
$this->setState('userid', $user->id);
$this->setState('username', $this->username);
$this->errorCode = self::ERROR_NONE;
}
return $this->errorCode == self::ERROR_NONE;
}
示例5: 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()
{
$username = $this->username;
$password = $this->password;
$user = user::model()->find(array('condition' => "username='{$username}'"));
if (!empty($user)) {
if ($password == $user->password) {
$this->errorCode = self::ERROR_NONE;
$this->setState('user', $user->username);
$this->setState('id', $user->id);
} else {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
}
} else {
$this->errorCode = self::ERROR_USERNAME_INVALID;
}
return !$this->errorCode;
}
示例6: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
*/
public function loadModel()
{
if ($this->_model === null) {
if (isset($_GET['id'])) {
$this->_model = user::model()->findbyPk($_GET['id']);
}
if ($this->_model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
}
return $this->_model;
}
示例7: array
?>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="span2">
<?php
echo $form->labelEx($model, 'created_by');
?>
</div>
<div class="col-sm-8 clearLeftPadding">
<?php
//echo $form->textField($model,'created_by');
echo $form->dropDownList($model, 'created_by', CHtml::listData(user::model()->findAll(array('select' => 'id, username', 'order' => 'username')), 'id', 'username'), array('empty' => '- Select -'));
?>
<?php
echo $form->error($model, 'created_by');
?>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="span2">
<?php
echo $form->labelEx($model, 'is_current');
?>
</div>
示例8: activeEmployer
public static function activeEmployer($id)
{
$user = user::model()->findByPk($id);
$user->activated = 1;
$user->save(false);
}
示例9: actionPassword
public function actionPassword()
{
$password = 'abc123456';
$user = user::model()->createPassword($password);
var_dump($user);
}
示例10: actionUpdatepw
public function actionUpdatepw()
{
if (!API_UPDATEPW) {
echo API_RETURN_FORBIDDEN;
}
$username = $_GET['username'];
$password = $_GET['password'];
$user = user::model()->findByAttributes(array('username' => $username));
if ($user !== null) {
$user->password = md5($password);
if ($user->save()) {
echo API_RETURN_SUCCEED;
} else {
echo API_RETURN_FAILED;
}
} else {
echo API_RETURN_FAILED;
}
}
示例11: model
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return user the static model class
*/
public static function model($className = __CLASS__)
{
return parent::model($className);
}