本文整理汇总了PHP中backend\models\User::updateAll方法的典型用法代码示例。如果您正苦于以下问题:PHP User::updateAll方法的具体用法?PHP User::updateAll怎么用?PHP User::updateAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend\models\User
的用法示例。
在下文中一共展示了User::updateAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDelete
/**
* Deletes an existing User model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
//if($id == '2') throw new HttpException(500, 'No Auth');
User::updateAll(['status' => User::STATUS_DELETED], ['id' => $id]);
//$this->findModel($id)->delete();
return $this->redirect(['index']);
}
示例2: setStatus
public function setStatus($id, $status = 1)
{
if (!in_array($status, [0, 1]) || $id == 1) {
return false;
}
return User::updateAll(['status' => $status], 'id = :id', [':id' => $id]);
}
示例3: actionActivate
/**
* Activate
*
* <b>Request Type </b>: GET<br/>
* <b>Request Endpoint </b>: http://{server-domain}/api/old-site/activate?code=abcd1234abcd1234<br/>
*
**/
public function actionActivate()
{
$code = $this->getQuery('code');
if (empty($code)) {
$this->_activateFail(0);
//此链接无效,请联系管理员
}
$validation = Validation::findOne(['code' => $code]);
if (empty($validation)) {
$this->_activateFail(0);
//此链接无效,请联系管理员
}
if (empty($validation->expire) || MongodbUtil::isExpired($validation->expire)) {
$this->_activateFail(1);
//'此链接已过期,请联系管理员'
}
$userId = $validation->userId;
if (User::updateAll(['isActivated' => User::ACTIVATED], ['_id' => $userId])) {
$validation->delete();
$this->redirect('/old/activate?type=0&link=' . urlencode('/site/login'));
Yii::$app->end();
}
$this->_activateFail(1);
//'此链接已过期,请联系管理员'
}