当前位置: 首页>>代码示例>>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;未经允许,请勿转载。