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


PHP ActiveDataProvider::getTotalCount方法代码示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Collection::find()->where(['author_id' => Yii::$app->user->id])]);
     $totalCount = $dataProvider->getTotalCount();
     $pages = new Pagination(['totalCount' => $totalCount]);
     return $this->render('index', ['models' => $dataProvider->getModels(), 'pages' => $pages]);
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:7,代码来源:CollectionController.php

示例2: actionList

 public function actionList($event_id)
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $dp = new ActiveDataProvider();
     $dp->query = Comment::find()->with('user')->where(['event_id' => $event_id])->orderBy(['id' => SORT_DESC]);
     $dp->pagination->pageSize = 6;
     return ['items' => $dp->getModels(), 'pageCount' => $dp->getPagination()->getPageCount(), 'totalCount' => $dp->getTotalCount(), 'page' => $dp->pagination->page, 'count' => $dp->getCount()];
 }
开发者ID:KPEMATOP,项目名称:findspree_old,代码行数:8,代码来源:CommentController.php

示例3: actionIndex

 /**
  * Lists all Message models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Message::find()->select('MAX(id) AS id, COUNT(id) AS msgCount')->where(['user_id' => Yii::$app->user->id])->groupBy('friend_id')->asArray()->orderBy('id desc')]);
     $arr = $dataProvider->getModels();
     $ids = ArrayHelper::getColumn($arr, 'id');
     $models = Message::find()->with('senderUser', 'receiverUser')->where(['id' => $ids])->all();
     $pages = new Pagination(['totalCount' => $dataProvider->getTotalCount()]);
     return $this->render('index', ['models' => $models, 'count' => ArrayHelper::getColumn($arr, 'msgCount'), 'pages' => $pages]);
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:13,代码来源:MessageController.php

示例4: actionFavorite

 public function actionFavorite($id)
 {
     $this->layout = '//u';
     $user = User::findOne($id);
     \Yii::$app->view->params['model'] = $user;
     $dataProvider = new ActiveDataProvider(['query' => Collection::find()->where(['author_id' => $id])]);
     $totalCount = $dataProvider->getTotalCount();
     $pages = new Pagination(['totalCount' => $totalCount]);
     return $this->render('favorites', ['models' => $dataProvider->getModels(), 'pages' => $pages, 'author' => $user]);
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:10,代码来源:UserController.php

示例5: actionIndex

 public function actionIndex($cid = '')
 {
     $key = Yii::$app->request->get('key');
     if ($key) {
         $where = ['like', 'name', $key];
     } else {
         $where = [];
     }
     $query = Goods::find()->where($where);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => Yii::$app->params['defaultPageSizeProduct']], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     return $this->render('index', ['models' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination, 'totalItems' => $dataProvider->getTotalCount()]);
 }
开发者ID:James88,项目名称:www.yubin.com,代码行数:12,代码来源:PriceController.php

示例6: actionSelect

 /**
  * Allows the current user to select the active board from his/her board options
  */
 public function actionSelect()
 {
     $userBoardId = explode(',', User::findOne(Yii::$app->getUser()->id)->board_id);
     $userBoards = new ActiveDataProvider(['query' => Board::find()->where(['id' => $userBoardId])]);
     $boardCount = $userBoards->getTotalCount();
     if ($boardCount == 0) {
         // No Boards, log user out
         Yii::$app->user->logout();
         return $this->render('noBoard');
     } elseif ($boardCount == 1) {
         // Only one board for user, activate it automatically
         $activeBoardId = $userBoards->getModels()[0]->id;
         $this->redirect(['activate', 'id' => $activeBoardId]);
     } else {
         // USer must select which board to activate
         return $this->render('select', ['userBoards' => $userBoards]);
     }
 }
开发者ID:highestgoodlikewater,项目名称:banthecan,代码行数:21,代码来源:BoardController.php

示例7: actionOutbox

 /**
  * [actionInbox description]
  *
  * @todo  combine w/ actionInbox()
  * @version  2.4.0
  * @param  integer $id
  * @return array
  */
 public function actionOutbox($id = null)
 {
     /* if (!(isset($id) && $this->isModerator())) {
                 $id = \Yii::$app->user->identity->id ;
             }
     
             $model = new BbiiMessage;
             // $model->unsetAttributes();  // clear any default values
             if (isset(\Yii::$app->request->get()['BbiiMessage'])) {
                 $model->load(\Yii::$app->request->get()['BbiiMessage']);
             }
             // restrict filtering to own outbox
             $model->sendfrom = $id;
             $model->outbox = 1;
             
             return $this->render('outbox', array(
                 'model' => $model,
                 'count' => $this->getMessageCount(),
             )); */
     $model = new ActiveDataProvider(['query' => BbiiMessage::find()->where(['sendto' => \Yii::$app->user->identity->id, 'outbox' => 1])->orderBy('create_time DESC'), 'sort' => false]);
     return $this->render('outbox', array('outboxCount' => $model->getTotalCount(), 'model' => $model));
 }
开发者ID:sourcetoad,项目名称:bbii2,代码行数:30,代码来源:MessageController.php

示例8: actionView

 /**
  * Displays a single Estimate model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $dataProvider = new ActiveDataProvider(['query' => $model->getEntries()->with('product.supplier')]);
     $dataProvider->sort = ['defaultOrder' => ['rank' => SORT_ASC]];
     // Set last page as default
     $pagination = $dataProvider->getPagination();
     $page = Yii::$app->request->getQueryParam($pagination->pageParam);
     if (!$page) {
         $pagination->totalCount = $dataProvider->getTotalCount();
         $page = $pagination->getPageCount() - 1;
         $pagination->setPage($page);
     }
     if (Yii::$app->request->post('hasEditable')) {
         $id = Yii::$app->request->post('editableKey');
         $entry = EstimateEntry::findOne($id);
         $out = Json::encode(['output' => '', 'message' => '']);
         $post = [];
         $posted = current($_POST['EstimateEntry']);
         $post['EstimateEntry'] = $posted;
         if ($entry->load($post)) {
             if ($entry->save()) {
                 $entry->estimate->doEstimate();
             }
             $output = '';
             if (isset($posted['status'])) {
                 $output = $entry->statusLabel;
             }
             $out = Json::encode(['output' => $output, 'message' => $entry->getErrors()]);
         }
         // return ajax json encoded response and exit
         echo $out;
         return;
     }
     return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider]);
 }
开发者ID:stupidusername,项目名称:bukmark,代码行数:41,代码来源:EstimateController.php

示例9: actionEventSubscribers

 /**
  * @param $event_id
  * @return array Вывод подписчиков на страницу события
  * Вывод подписчиков на страницу события
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionEventSubscribers($event_id)
 {
     if (!\Yii::$app->request->isAjax) {
         throw new NotFoundHttpException();
     }
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $dp = new ActiveDataProvider();
     $dp->query = EventSubscriber::find()->with('user')->where(['event_id' => $event_id])->orderBy(['id' => SORT_DESC]);
     $dp->pagination->pageSize = 12;
     return ['items' => $dp->getModels(), 'pageCount' => $dp->getPagination()->getPageCount(), 'totalCount' => $dp->getTotalCount(), 'page' => $dp->pagination->page, 'count' => $dp->getCount()];
 }
开发者ID:KPEMATOP,项目名称:findspree_old,代码行数:17,代码来源:EventController.php

示例10: jgridBooks

 /**
  * 
  * @param array $data [page, limit, sort_column, sort_order, filters=json] 
  * @return multitype:multitype:Ambigous <NULL> multitype:unknown string   |\stdClass
  */
 public static function jgridBooks(array $data)
 {
     $query = self::jqgridPepareQuery($data);
     $data['limit'] = empty($data['limit']) || $data['limit'] <= 0 || $data['limit'] > 30 ? 10 : $data['limit'];
     $data['page'] = empty($data['page']) || $data['page'] <= 0 ? 1 : $data['page'];
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $data['limit'], 'page' => $data['page'] - 1]]);
     $books = $provider->getModels();
     $to_array = function ($obj_arr, $query) {
         $ar = [];
         foreach ($obj_arr as $o) {
             /* @var $o Books */
             $book = [];
             $attr = $o->getAttributes($o->fields());
             //jgrid required no assoc array same order
             foreach ($query->select as $col) {
                 if ($col == 'created_date') {
                     $book[] = \Yii::$app->formatter->asDate($attr[$col], 'php:d-m-Y');
                 } else {
                     $book[] = $attr[$col];
                 }
             }
             $ar[] = ['id' => $attr['book_guid'], 'cell' => $book];
         }
         return $ar;
     };
     return self::jqgridPrepareResponse($provider->getPagination()->getPage(), $provider->getPagination()->getPageCount(), $provider->getTotalCount(), $to_array($books, $query));
 }
开发者ID:aekkapun,项目名称:yii2-mylib,代码行数:32,代码来源:Books.php

示例11: actionView

 public function actionView($id, $page = 1, $all = 1)
 {
     error_reporting(1);
     $model = $this->findModel($id);
     $defaultPageSize = 20;
     $offset = ($page - 1) * $defaultPageSize;
     if (!$all) {
         $queryWord = [$model->name];
     } else {
         $children = $model->children()->indexBy('id')->asArray()->all();
         $childrenValues = ArrayHelper::merge([$model->id => $model->name], ArrayHelper::getColumn($children, 'name'));
         $queryWord = ArrayHelper::merge(["OR"], $childrenValues);
     }
     $query = Feed::find();
     $condition = $queryWord;
     $query->where($condition);
     //        $condition = ['obj_type'=>App::OBJ_TYPE_FEED];
     //        $query->andwhere($condition);
     $query->offset($offset)->limit($defaultPageSize)->orderBy("id desc");
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $defaultPageSize]]);
     $feeds = $dataProvider->getModels();
     $totalCount = $dataProvider->getTotalCount();
     $pages = new Pagination(['totalCount' => $totalCount, 'defaultPageSize' => $defaultPageSize]);
     return $this->render("view", ['model' => $model, 'feeds' => $feeds, 'pages' => $pages]);
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:25,代码来源:TagController.php


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