当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::findAll方法代码示例

本文整理汇总了PHP中app\models\Users::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::findAll方法的具体用法?PHP Users::findAll怎么用?PHP Users::findAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Users的用法示例。


在下文中一共展示了Users::findAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendMailToModerator

 public function sendMailToModerator($news, $subject)
 {
     $subquery = (new \yii\db\Query())->select('user_id')->from('relation_categories')->where(['category_id' => $news->category_id]);
     $users = Users::findAll(['id' => $subquery]);
     foreach ($users as $user) {
         $emails[] = $user->email;
     }
     $body = sprintf('%s <br />
         Ссылка на новость - %s', $subject['moderator'], $this->urlToNews($news->id));
     $this->sendMail($emails, $subject['moderator'], $body);
 }
开发者ID:igribov,项目名称:question-list,代码行数:11,代码来源:Mail.php

示例2: actionCreate

 /**
  * Creates a new MessagesUsers model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new MessagesUsers();
     $type = Yii::$app->request->get('type');
     if (Yii::$app->request->isPost) {
         $param = Yii::$app->request->post();
         if ($param['user_type'] == 'user_name') {
             $userId = Users::getIdByName($param['MessagesUsers']['users_id']);
             if (empty($userId)) {
                 throw new ServerErrorHttpException('不存在的用户姓名!');
             }
             $model->messages_id = $param['MessagesUsers']['messages_id'];
             $model->type = $param['MessagesUsers']['type'];
             $model->users_id = $userId;
             $model->content = $param['MessagesUsers']['content'];
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         } elseif ($param['user_type'] == 'user_level') {
             $levelId = Level::getIdByName($param['MessagesUsers']['users_id']);
             if (empty($levelId)) {
                 throw new ServerErrorHttpException('不存在的级别名称!');
             }
             $usersList = Users::findAll(['level_id' => $levelId, 'status' => 1]);
             if (!empty($usersList)) {
                 foreach ($usersList as $key => $val) {
                     $messagesUsersInfo['messages_id'] = $param['MessagesUsers']['messages_id'];
                     $messagesUsersInfo['type'] = $param['MessagesUsers']['type'];
                     $messagesUsersInfo['users_id'] = $val['id'];
                     $messagesUsersInfo['content'] = $param['MessagesUsers']['content'];
                     $messagesUsersInfo['create_time'] = date('Y-m-d H:i:s', time());
                     $messagesUsersInfo['create_user'] = 'admin';
                     $messagesUsersInfo['update_time'] = date('Y-m-d H:i:s', time());
                     $messagesUsersInfo['update_user'] = 'admin';
                     MessagesUsers::addInfo($messagesUsersInfo);
                 }
                 return $this->redirect('index');
             }
         } elseif ($param['user_type'] == 'all_user') {
             $usersList = Users::getAll();
             if (!empty($usersList)) {
                 foreach ($usersList as $key => $val) {
                     $messagesUsersInfo['messages_id'] = $param['MessagesUsers']['messages_id'];
                     $messagesUsersInfo['type'] = $param['MessagesUsers']['type'];
                     $messagesUsersInfo['users_id'] = $val['id'];
                     $messagesUsersInfo['content'] = $param['MessagesUsers']['content'];
                     $messagesUsersInfo['create_time'] = date('Y-m-d H:i:s', time());
                     $messagesUsersInfo['create_user'] = admin;
                     $messagesUsersInfo['update_time'] = date('Y-m-d H:i:s', time());
                     $messagesUsersInfo['update_user'] = 'admin';
                     MessagesUsers::addInfo($messagesUsersInfo);
                     return $this->redirect('index');
                 }
             }
         } else {
             throw new ServerErrorHttpException('参数错误!');
         }
     } else {
         return $this->render('create', ['model' => $model, 'type' => empty($type) ? '1' : $type]);
     }
 }
开发者ID:hanxiao84322,项目名称:coach_system,代码行数:66,代码来源:MessagesUsersController.php

示例3: actionBulkDelete

 /**
  * Delete multiple existing Users model.
  * For ajax request will return json object
  * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionBulkDelete()
 {
     $request = Yii::$app->request;
     $pks = $request->post('pks');
     // Array or selected records primary keys
     foreach (Users::findAll(json_decode($pks)) as $model) {
         $model->delete();
     }
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ['forceClose' => true, 'forceReload' => true];
     } else {
         /*
          *   Process for non-ajax request
          */
         return $this->redirect(['index']);
     }
 }
开发者ID:alfredosotil,项目名称:swinnapp,代码行数:28,代码来源:UsersController.php


注:本文中的app\models\Users::findAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。