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


PHP CPagination类代码示例

本文整理汇总了PHP中CPagination的典型用法代码示例。如果您正苦于以下问题:PHP CPagination类的具体用法?PHP CPagination怎么用?PHP CPagination使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

 public function run()
 {
     $params = array();
     $criteria = new CDbCriteria();
     //        $criteria->select = array('id,username,fullname,phone,address,status');
     $criteria->select = '*';
     if (isset($this->team_lear_id) and $this->team_lear_id != '') {
         $criteria->addCondition('team_lear_id=' . $this->team_lear_id);
     }
     $criteria->params = $params;
     $total = ATrainingTeam::model()->count($criteria);
     $offset = $this->limit * ($this->page - 1);
     $criteria->limit = $this->limit;
     $criteria->offset = $offset;
     $data = ATrainingTeam::model()->findAll($criteria);
     $listTrainee = array();
     if (!empty($data)) {
         foreach ($data as $item) {
             $listTrainee[] = CJSON::decode(CJSON::encode($item->pls_user));
         }
     }
     $data = $listTrainee;
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $pages->applyLimit($criteria);
     $this->render($this->view, array('data' => $data, 'pages' => $pages));
 }
开发者ID:nguyendvphp,项目名称:onlinetraining,代码行数:27,代码来源:wg_dataUser_Team.php

示例2: actionFind

 public function actionFind()
 {
     if (isset($_POST['flightNumber'])) {
         $current = date('Y-m-d');
         $flightNumber = $_POST['flightNumber'];
         $criteria = new CDbCriteria();
         $criteria->join = 'LEFT JOIN tbl_mry_user ON tbl_mry_plan.userId=tbl_mry_user.userId';
         $criteria->addCondition('flightNumber=:flightNumber');
         $criteria->params = array(':flightNumber' => $flightNumber);
         $criteria->order = 'startDate DESC';
         $UserModel = User::model();
         $total = $UserModel->count($criteria);
         $pager = new CPagination($total);
         $pager->pageSize = 10;
         $pager->applyLimit($criteria);
         $UserList = $UserModel->findAll($criteria);
         //删除PASSWORD相关的信息
         $dataFormat = new DataFormat();
         $format = $dataFormat->format($userList, null, null);
         $clientFlash = new ClientFlash();
         if ($total > 0) {
             $clientFlash->pushMobile(0, $format);
         } else {
             _echo(3, 数据为空);
         }
     }
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:27,代码来源:SameFlightController.php

示例3: actionIndex

 public function actionIndex($is_product = 1)
 {
     if (!empty($_POST)) {
         $is_new_product = $is_product;
         $images = CUploadedFile::getInstancesByName('images');
         if (isset($images) && count($images) > 0) {
             // go through each uploaded image
             foreach ($images as $image => $pic) {
                 $model = new Slides();
                 $imageType = explode('.', $pic->name);
                 $imageType = $imageType[count($imageType) - 1];
                 $imageName = md5(uniqid()) . '.' . $imageType;
                 if ($pic->saveAs(Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName)) {
                     $model->image = $imageName;
                     $model->name = $pic->name;
                     $model->is_product = $is_new_product;
                     $model->save();
                     Yii::app()->user->setFlash('success', translate('Thêm thành công.'));
                 }
                 // handle the errors here, if you want
             }
         }
         PIUrl::createUrl('/admin/slides/index', array('is_product' => $is_product));
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("is_product= {$is_product}");
     $criteria->order = 'id DESC';
     $count = Slides::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = 6;
     $pages->applyLimit($criteria);
     $model = Slides::model()->findAll($criteria);
     $this->render('index', compact('model', 'pages'));
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:35,代码来源:SlidesController.php

示例4: actionIndexdata

 public function actionIndexdata()
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     //'BrandID,BrandName,Pinyin,Remarks';
     $criteria->order = 'CreateTime desc';
     $criteria->addCondition('OrganID=' . Commonmodel::getOrganID());
     $res = MakeGoodsBrand::model()->findAll($criteria);
     $count = count($res);
     $page = new CPagination($count);
     $page->pageSize = $_GET['rows'];
     $page->applyLimit($criteria);
     $res = MakeGoodsBrand::model()->findAll($criteria);
     $data = array();
     if (is_array($res)) {
         foreach ($res as $key => $val) {
             $data[$key] = $val->attributes;
             $sQl = 'select count(b.goods_brand)as number from tbl_make_goods a,tbl_make_goods_version b where b.goods_brand=' . $val->BrandID . ' and b.organID=' . $val->OrganID . ' and a.IsSale=0 and a.ISdelete=0 and  a.NewVersion=b.version_name and a.id=b.goods_id';
             $query = Yii::app()->db->createCommand($sQl)->queryAll();
             $data[$key]['Number'] = $query[0]['number'];
         }
     }
     // var_dump($data);
     echo json_encode(array('total' => $count, 'rows' => $data ? $data : array()));
 }
开发者ID:zwq,项目名称:unpei,代码行数:25,代码来源:GoodsbrandController.php

示例5: actionIndex

 /**
  * 显示问题列表
  */
 public function actionIndex()
 {
     $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`update_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`,`{{question}}`.`focus_count`,`{{question}}`.`comment_count`,`{{question}}`.`best_answer`,`{{question}}`.`ip`,`{{users}}`.`username`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\t\t\t\t\n\t\t\t\tleft join `{{users}}` on (`{{users}}`.`uid` = `{{question}}`.`published_uid`)";
     $condition = array();
     //根据uid搜索
     if (isset($_GET['uid'])) {
         $condition[] = "`{{users}}`.`uid`={$_GET['uid']} ";
     }
     if (isset($_POST['content'])) {
         $condition[] = " `{{question}}`.`question_content` like '%{$_POST['content']}%'";
     }
     $conditions = implode('AND', $condition);
     //var_dump($conditions);
     if ($conditions) {
         $conditions = ' where ' . $conditions;
         $sql .= $conditions;
     }
     $sql .= " order by `{{question}}`.`add_time` desc ";
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $models = $connection->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = 12;
     $pages->applylimit($criteria);
     $models = $connection->createCommand($sql . " LIMIT :offset,:limit");
     $models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $models->bindValue(':limit', $pages->pageSize);
     $models = $models->queryAll();
     $this->render('index', array('models' => $models, 'pages' => $pages, 'count' => $count));
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:34,代码来源:QuestionController.php

示例6: actionShow

 public function actionShow()
 {
     // handle space visibility changes
     if (isset($_POST['reputationUsers'])) {
         $user = $this->getUser();
         $userSpace = Yii::app()->request->getParam('reputationUsers');
         foreach ($userSpace as $space) {
             if (isset($_POST['reputationUser_' . $space])) {
                 $userSettings = Yii::app()->request->getParam('reputationUser_' . $space);
                 $reputationUser = ReputationUser::model()->findByAttributes(array('space_id' => $space, 'user_id' => $user->id));
                 if ($reputationUser != null) {
                     $reputationUser->visibility = isset($userSettings['visibility']) && $userSettings['visibility'] == 1 ? 1 : 0;
                     $reputationUser->save();
                 }
             }
         }
         Yii::app()->user->setFlash('data-saved', Yii::t('SpaceModule.controllers_AdminController', 'Saved'));
     }
     $user = $this->getUser();
     $criteria = new CDbCriteria();
     $criteria->condition = 'user_id=:userId';
     $criteria->order = 'space_id ASC';
     $criteria->params = array(':userId' => $user->id);
     $itemCount = ReputationUser::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $reputations = ReputationUser::model()->findAll($criteria);
     $this->render('userReputation', array('user' => $user, 'reputations' => $reputations, 'pages' => $pages));
 }
开发者ID:plantoschka,项目名称:humhub-modules-reputation,代码行数:30,代码来源:ProfileReputationController.php

示例7: run

 public function run()
 {
     $model = new Comment();
     //条件
     $criteria = new CDbCriteria();
     $type = trim(Yii::app()->request->getParam('type'));
     $type && $criteria->addColumnCondition(array('type' => $type));
     $status = trim(Yii::app()->request->getParam('status'));
     $status && $criteria->addColumnCondition(array('status' => $status));
     $title = trim(Yii::app()->request->getParam('content'));
     $title && $criteria->addSearchCondition('content', $title);
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     //全部类型
     $model_types = ModelType::model()->findAll();
     Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     $this->controller->render('index', array('model' => $model, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:25,代码来源:IndexAction.php

示例8: actionIndex

 /**
  * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
  * Requests come in, are verified, and then pulled from the database dynamically
  * Shows all blog posts for a particular category_id
  * @param $id	- The content ID that we want to pull from the database
  * @return $this->render() - Render of page that we want to display
  **/
 public function actionIndex($id = NULL)
 {
     // Run a pre check of our data
     $this->beforeCiiAction($id);
     // Retrieve the data
     $category = Categories::model()->findByPk($id);
     $this->breadcrumbs = Categories::model()->getParentCategories($id);
     // Parse Metadata
     $meta = Categories::model()->parseMeta($category->metadata);
     $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => $category->name)));
     $layout = isset($meta['layout']) ? $meta['layout']['value'] : 'default';
     // Set the layout
     $this->setLayout($layout);
     $data = array();
     $pages = array();
     $itemCount = 0;
     $pageSize = Cii::getConfig('categoryPaginationSize', 10);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition("category_id = " . $id)->addCondition('password = ""');
     $criteria->limit = $pageSize;
     $criteria->order = 'created DESC';
     $itemCount = Content::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = $pageSize;
     $criteria->offset = $criteria->limit * $pages->getCurrentPage();
     $data = Content::model()->findAll($criteria);
     $pages->applyLimit($criteria);
     $this->render('index', array('id' => $id, 'category' => $category, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages, 'meta' => array('description' => $category->getDescription())));
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:35,代码来源:CategoriesController.php

示例9: run

 public function run()
 {
     $this->controller->_seoTitle = '交易记录 - ' . $this->controller->_setting['site_name'];
     $this->controller->loadModel();
     $model = new UserTrade();
     $criteria = new CDbCriteria();
     //查询条件
     $create_time_start = Yii::app()->request->getParam('create_time_start');
     $create_time_end = Yii::app()->request->getParam('create_time_end');
     $trade_type = Yii::app()->request->getParam('trade_type');
     $trade_status = Yii::app()->request->getParam('trade_status');
     $create_time_start && $criteria->addBetweenCondition('time_create', strtotime($create_time_start), strtotime($create_time_end));
     if ($trade_type && $trade_type != 'all') {
         $criteria->addColumnCondition(['type' => $trade_type]);
     }
     if ($trade_status && $trade_status != 'all') {
         $criteria->addColumnCondition(['status' => $trade_status]);
     }
     $criteria->addColumnCondition(array('user_id' => Yii::app()->user->id));
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $lists = $model->findAll($criteria);
     //加载css js
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/jquery/jquery.js");
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/My97DatePicker/WdatePicker.js", CClientScript::POS_END);
     $this->controller->render('list_trade', array('lists' => $lists, 'pages' => $pages, 'create_time_start' => $create_time_start, 'create_time_end' => $create_time_end, 'trade_type' => $trade_type, 'trade_status' => $trade_status));
 }
开发者ID:github-zjh,项目名称:task,代码行数:29,代码来源:TradeAction.php

示例10: actioncxIndex

 public function actioncxIndex()
 {
     //print_r( ucfirst($this->getId() ) );
     //$this->actionId     = $this->getAction()->getId();
     $controllerId = $this->controllerId;
     $criteria = new CDbCriteria();
     if (isset($_GET['keyword']) || !empty($_GET['keyword']) || strlen($_GET['keyword']) > 0) {
         $keyword = trim($_GET['keyword']);
         $criteria->condition = 'title like :keyword ';
         $criteria->params = array(':keyword' => "%{$keyword}%");
         $is_partial = true;
     }
     $imodel = new $controllerId();
     $item_count = call_user_func(array($imodel, 'count'), $criteria);
     $page_size = 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->header = '跳转到:';
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $list = call_user_func(array($imodel, 'findAll'), $criteria);
     if ($is_partial) {
         $this->renderPartial('_index', array('list' => $list, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
     } else {
         $this->render('index', array('list' => $list, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
     }
 }
开发者ID:paranoidxc,项目名称:iwebhost,代码行数:35,代码来源:ArticleController.php

示例11: actionIndex

 public function actionIndex()
 {
     $id = $_REQUEST['id'];
     $this->data['cur_moduleid'] = $id;
     $module = Yii::app()->cache->get("module_" . $id);
     if ($module == false) {
         $module = $this->connection->createCommand("select * from xm_module where module_id = " . $id)->queryRow();
         Yii::app()->cache->set("module_" . $id, $module);
     }
     $this->data['module'] = $module;
     /*右侧导航栏*/
     $topid = $this->getTopIdFromIDEN($module['iden']);
     $modulequeue = Yii::app()->cache->get("modulequeue_" . $topid);
     if ($modulequeue == false) {
         $modulequeue = $this->getQueueModulesById($topid);
         Yii::app()->cache->set("modulequeue_" . $topid, $modulequeue);
     }
     $this->data['modulequeue'] = $modulequeue;
     $criteria = new CDbCriteria();
     $criteria->addCondition('module_id=' . $id, 'AND');
     $criteria->order = "createtime desc";
     $count = Message::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 10;
     $pager->applyLimit($criteria);
     $articles = Message::model()->findAll($criteria);
     $this->data['pages'] = $pager;
     $this->data['list'] = $articles;
     Yii::app()->params['TITLE'] = $module['category'];
     Yii::app()->params['APPKEYWORDS'] = $module['category'];
     Yii::app()->params['APPDESCRIPTION'] = $module['category'];
     $this->render('index', $this->data);
 }
开发者ID:Toney,项目名称:xmcms,代码行数:33,代码来源:MessageController.php

示例12: getWishListForWeb

 public function getWishListForWeb($user_id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "user_id = {$user_id}";
     $wishlists = Wishlist::model()->findAll($criteria);
     $wishlist_arr = array();
     foreach ($wishlists as $wishlist) {
         $wishlist_arr[] = $wishlist->post_id;
     }
     //var_dump($wishlist_arr); die;
     $returnArr = array();
     $criteria_post = new CDbCriteria();
     $criteria_post->addInCondition('t.post_id', $wishlist_arr);
     $count = Posts::model()->count($criteria_post);
     $pages = new CPagination($count);
     $pages->validateCurrentPage = FALSE;
     $pages->pageSize = Yii::app()->params['RESULT_PER_PAGE'];
     $pages->applyLimit($criteria_post);
     $posts = Posts::model()->findAll($criteria_post);
     $is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER');
     $profile = User::model()->findByPk($user_id);
     foreach ($posts as $post) {
         $itemArr = Posts::model()->getPostById($post->post_id, Yii::app()->session['user_id']);
         $returnArr[] = $itemArr;
     }
     return array('data' => $returnArr, 'pages' => $pages, 'profile' => $profile, 'is_followed' => $is_followed);
     // return FALSE;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:28,代码来源:Wishlist.php

示例13: run

 public function run()
 {
     $params = array();
     $criteria = new CDbCriteria();
     $criteria->select = array('lecture_name,training_minute,id,lecture_type');
     if (isset($this->lecture_name) and $this->lecture_name != '') {
         $keyword = addcslashes($this->lecture_name, '%_');
         $criteria->addCondition('lecture_name LIKE :keyword');
         $params[':keyword'] = "%{$keyword}%";
     }
     if (isset($this->lecture_cat) and $this->lecture_cat != '') {
         $criteria->addCondition('lecture_cat_id=' . $this->lecture_cat);
     }
     if (isset($this->trainer) and $this->trainer != '') {
         $criteria->addCondition('created_by=' . $this->trainer);
     }
     if (!empty(Yii::app()->user->id) and Yii::app()->session['group_id'] == 1) {
         $criteria->addCondition('created_by=' . Yii::app()->user->id);
     }
     $criteria->params = $params;
     $criteria->order = 'created_date DESC';
     $total = Lecture::model()->count($criteria);
     $offset = $this->limit * ($this->page - 1);
     $criteria->limit = $this->limit;
     $criteria->offset = $offset;
     $data = Lecture::model()->findAll($criteria);
     if (!empty($data)) {
         $data = CJSON::decode(CJSON::encode($data));
     }
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $pages->applyLimit($criteria);
     $this->render($this->view, array('data' => $data, 'pages' => $pages));
 }
开发者ID:nguyendvphp,项目名称:onlinetraining,代码行数:34,代码来源:wg_dataLecture.php

示例14: getList

 /**
  * 获取一定条件下的文章
  * @param array $params = ('condition'=> '额外条件', 'order'=>'排序', 'with'=>'关联表', 'limit'=>'条数', 'page'=>'是否分页')
  * @param $pages 分页widget
  * @return array
  */
 public static function getList($params = array(), &$pages = null)
 {
     $pages = array();
     $params['condition'] = isset($params['condition']) ? $params['condition'] : '';
     $params['order'] = isset($params['order']) ? $params['order'] : '';
     $params['with'] = isset($params['with']) ? $params['with'] : '';
     $params['limit'] = isset($params['limit']) ? $params['limit'] : '';
     $params['page'] = isset($params['page']) ? $params['page'] : '';
     //组合条件
     $criteria = new CDbCriteria();
     $criteria->condition = 't.status=:status';
     $params['condition'] && ($criteria->condition .= $params['condition']);
     $criteria->order = $params['order'] ? $params['order'] : 't.id DESC';
     $criteria->with = array('catalog');
     $criteria->select = "t.title, t.id,t.title_style, ";
     $criteria->select .= " t.copy_from, t.copy_url, t.update_time,t.introduce, t.tags, t.view_count";
     $criteria->params = array(':status' => 'Y');
     $params['with'] && ($criteria->with = (array) $params['with']);
     $limit = $params['limit'] > 0 ? intval($params['limit']) : 15;
     //是否分页
     if ($params['page']) {
         //分页
         $count = self::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = $limit;
         $pages->applyLimit($criteria);
     } else {
         $criteria->limit = $limit;
     }
     $data = self::model()->findAll($criteria);
     return $data ? $data : array();
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:38,代码来源:Post.php

示例15: actionMembers

 /**
  * Action for the members section of the directory
  *
  * @todo Dont pass lucene hits to view, build user array inside of action
  */
 public function actionMembers()
 {
     $details = Yii::app()->db->createCommand()->select('companyname, username, firstname, lastname, title, guid')->from('user, profile')->where('user.id=profile.user_id and group_id=3')->order('companyname')->queryAll();
     $companycount = Yii::app()->db->createCommand()->select('count(distinct(companyname)) as count')->from('profile')->where('companyname not like \'student\'')->order('companyname')->queryAll();
     $item_count = (int) $companycount[0]["count"];
     $page_size = (int) $companycount[0]["count"];
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $end = $pages->offset + $pages->limit <= $item_count ? $pages->offset + $pages->limit : $item_count;
     $sample = array();
     $y = "";
     $i = 0;
     $j = 0;
     foreach ($details as $x) {
         if ($x["companyname"] != $y) {
             $sample[$i++] = array('cname' => $x["companyname"], 'detail' => array());
             $j = 0;
         }
         $sample[$i - 1]["detail"][$j++] = $x;
         $y = $x["companyname"];
     }
     $pg_content = array();
     for ($i = $pages->offset; $i < $end; $i++) {
         $pg_content[$i] = $sample[$i];
     }
     $this->render('members', array('item_count' => $item_count, 'page_size' => $page_size, 'items_count' => $item_count, 'pages' => $pages, 'sample' => $pg_content));
 }
开发者ID:skapl,项目名称:design,代码行数:32,代码来源:CompaniesController.php


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