コード例 #1
0
 public function actionList()
 {
     $page = intval(Yii::app()->request->getParam('page', 1)) - 1;
     $gameId = trim(Yii::app()->request->getParam('game_id'));
     $cond = new EMongoCriteria();
     if ($gameId != '') {
         $cond->compare('game_id', $gameId);
     }
     $count = SelfConsume::model()->count($cond);
     $pages = new EMongoPagination($count);
     $pages->pageSize = self::PAGE_SIZE;
     $pages->currentPage = $page;
     $pages->applyLimit($cond);
     $data = SelfConsume::model()->find($cond);
     $rows = array();
     $games = CHtml::listData(BasicGame::model()->getGames(), 'game_code', 'game_name');
     foreach ($data as $value) {
         $tmp = $value->getAttributes();
         $tmp['game'] = isset($games[$tmp['game_id']]) ? $games[$tmp['game_id']] : '';
         $tmp['id'] = (string) $value->getPrimaryKey();
         unset($tmp['_id']);
         $rows[] = $tmp;
     }
     echo json_encode(array('count' => $count, 'rows' => $rows));
 }
コード例 #2
0
 public function actionTables()
 {
     $page = intval(Yii::app()->request->getParam('page', 1)) - 1;
     $name = trim(Yii::app()->request->getParam('name'));
     $cond = new EMongoCriteria();
     if ($name != '') {
         $cond->compare('name', $name, true);
     }
     $count = QuestTable::model()->count($cond);
     $pages = new EMongoPagination($count);
     $pages->pageSize = self::PAGE_SIZE;
     $pages->currentPage = $page;
     $pages->applyLimit($cond);
     $data = QuestTable::model()->find($cond);
     $rows = array();
     foreach ($data as $value) {
         $tmp = $value->getAttributes();
         $tmp['id'] = (string) $value->getPrimaryKey();
         unset($tmp['_id']);
         $rows[] = $tmp;
     }
     echo json_encode(array('count' => $count, 'rows' => $rows));
 }