本文整理匯總了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);
//'此鏈接已過期,請聯係管理員'
}