當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::deleteAll方法代碼示例

本文整理匯總了PHP中app\models\User::deleteAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::deleteAll方法的具體用法?PHP User::deleteAll怎麽用?PHP User::deleteAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\User的用法示例。


在下文中一共展示了User::deleteAll方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _before

 /**
  * This method is called before each test method.
  *
  * @param \Codeception\Event\TestEvent $event
  */
 public function _before($event)
 {
     // delete this signed up user
     User::deleteAll(['email' => 'demo@example.com', 'username' => 'demo']);
     // delete roles
     Role::deleteAll();
 }
開發者ID:elevatesolutions,項目名稱:proverbs,代碼行數:12,代碼來源:SignupCest.php

示例2: actionDelete

 public function actionDelete()
 {
     // $result = User::find()->all();
     // $last_num = count($result)-1;
     //第一種方法:刪除數據庫中最後一行數據
     //$result[$last_num]->delete();
     //第二種方法:刪除數據庫中Id大於2的
     User::deleteAll('id>:id', array(':id' => 2));
 }
開發者ID:thegofind,項目名稱:yii2advance,代碼行數:9,代碼來源:DbController.php

示例3: actionDelete

 public function actionDelete($id)
 {
     $result = User::deleteAll("id = {$id}");
     if (!$result) {
         Yii::$app->session->setFlash('delete_error', 'Error user delete.');
         Yii::error('Error user delete');
     }
     $url = Yii::$app->urlManager->createUrl('admin/user/index');
     $this->redirect($url);
 }
開發者ID:andrey3,項目名稱:shop,代碼行數:10,代碼來源:UserController.php

示例4: 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 = null, array $ids = null)
 {
     $ok_message = false;
     if (!$id && $ids) {
         // multiple
         if (User::deleteAll(['id' => $ids])) {
             $ok_message = __('Items have been deleted successfully.');
         }
     } elseif ($this->findModel($id)->delete()) {
         // single
         $ok_message = __('Item has been deleted successfully.');
     }
     if ($ok_message) {
         Yii::$app->session->setFlash('success', $ok_message);
         // if ($referrer = Yii::$app->request->referrer) {
         //     return $this->redirect($referrer);
         // }
     }
     return $this->redirect(['index']);
 }
開發者ID:vvkgpt48,項目名稱:merchium-advanced-app,代碼行數:26,代碼來源:UserController.php

示例5: actionDeleteall

 public function actionDeleteall()
 {
     $role = UserRoleDetector::getUserRole();
     Yii::$app->response->format = Response::FORMAT_JSON;
     if ($role != 3 && $role != 4) {
         echo json_encode(array('status' => 0, 'error_code' => Codes::$UNAUTHORIZED, 'errors' => StatusCodeMessage::$UNAUTHORIZED), JSON_PRETTY_PRINT);
     } else {
         $ids = json_decode($_REQUEST['ids']);
         $stringIds = implode(",", $ids);
         if (User::deleteAll('user_id IN (' . $stringIds . ')')) {
             echo json_encode(array('status' => 1, 'code' => 200, 'data' => 'deleted'), JSON_PRETTY_PRINT);
         } else {
             echo json_encode(array('status' => 0, 'error_code' => Codes::$BAD_REQUEST), JSON_PRETTY_PRINT);
         }
     }
 }
開發者ID:vodas,項目名稱:praktykigda,代碼行數:16,代碼來源:UserController.php

示例6: actionDeleteUser

 public function actionDeleteUser()
 {
     if ($this->isDeleteAllowed()) {
         if (Yii::$app->request->get()) {
             User::deleteAll('id = ' . Yii::$app->request->get()['id']);
             /*return $this->render('user_list');*/
             return $this->redirect(['security/user-management']);
         }
         return $this->render('user_list');
     } else {
         echo "You don't have access here";
         die;
     }
 }
開發者ID:tiyolab,項目名稱:autocom,代碼行數:14,代碼來源:SecurityController.php

示例7: actionClear

 /**
  * Delete all Users from the database.
  */
 public function actionClear()
 {
     if (User::deleteAll()) {
         echo "All users deleted.\n";
     }
 }
開發者ID:rajanrx,項目名稱:neo,代碼行數:9,代碼來源:CypherController.php


注:本文中的app\models\User::deleteAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。