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


PHP CPagination::applylimit方法代码示例

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


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

示例1: 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

示例2: actionIndex

 public function actionIndex($uid)
 {
     //自己才能看自己的个人中心
     if ($uid != Yii::app()->user->id) {
         $this->redirect('/');
     }
     //显示用户资料
     $user_model = Users::model()->findByPk($uid);
     //获取ype
     if (isset($_GET['type']) && $_GET['type'] == 'focus') {
         //获取关注的问题
         $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`published_uid`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{question}}`.`answer_count`,`{{question}}`.`view_count` from `{{question}}` left join `{{question_focus}}` on (`{{question_focus}}`.`question_id`=`{{question}}`.`id`) where `{{question_focus}}`.`uid`={$uid} order by `{{question_focus}}`.`add_time` desc";
     } elseif (isset($_GET['type']) && $_GET['type'] == 'answer') {
         //获取回复的问题
         $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`published_uid`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{question}}`.`answer_count`,`{{question}}`.`view_count` from `{{question}}` left join `{{answer}}` on (`{{answer}}`.`question_id`=`{{question}}`.`id`) where `{{answer}}`.`uid`={$uid}";
     } else {
         //获取自己发布的问题
         $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`published_uid`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{question}}`.`answer_count`,`{{question}}`.`view_count` from `{{question}}` where `{{question}}`.`published_uid`={$uid} 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 = 10;
     $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('user_model' => $user_model, 'models' => $models, 'pages' => $pages, 'count' => $count));
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:32,代码来源:UserController.php

示例3: actionIndex

 public function actionIndex($id)
 {
     //搜索内容
     $sql = "select `{{question}}`.`id`,`{{topic}}`.`topic_title`,`{{question}}`.`question_content`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{question}}`.`view_count`,`{{question}}`.`answer_count` from `{{question}}` left join `{{topic_question}}` on (`{{topic_question}}`.`question_id`=`{{question}}`.`id`) left join `{{topic}}` on (`{{topic}}`.`id`=`{{topic_question}}`.`topic_id`) where `{{topic}}`.`id`={$id} ";
     $question_models = Yii::app()->db->createCommand($sql)->queryAll();
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $count = count($question_models);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applylimit($criteria);
     $question_models = $connection->createCommand($sql . " LIMIT :offset,:limit");
     $question_models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $question_models->bindValue(':limit', $pages->pageSize);
     $question_models = $question_models->queryAll();
     $this->render('index', array('count' => $count, 'question_models' => $question_models, 'pages' => $pages));
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:17,代码来源:TopicController.php

示例4: actionIndex

 public function actionIndex()
 {
     $sql = "select `{{users}}`.`uid`,`{{users}}`.`username`,`{{users}}`.`email`,`{{users}}`.`avatar_file`,`{{users}}`.`sex`,`{{users}}`.`birthday`,`{{users}}`.`reg_time`,`{{users}}`.`reg_ip`,`{{users}}`.`last_login`,`{{users}}`.`last_ip` from `{{users}}`";
     //查找用户
     if (isset($_POST['content'])) {
         $sql .= " where `{{users}}`.`username` like '%{$_POST['content']}%'";
     }
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $models = $connection->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = 14;
     $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,代码行数:20,代码来源:UserController.php

示例5: actionIndex

 public function actionIndex($word)
 {
     //获取搜索关键字
     if ($word == '') {
         $this->error('未填入搜索关键字');
     }
     //搜索内容
     $sql = "select `id`,`question_content`,`lock`,`best_answer`,`view_count`,`answer_count` from {{question}} where `question_content` like '%{$word}%'";
     $question_models = Yii::app()->db->createCommand($sql)->queryAll();
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $count = count($question_models);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applylimit($criteria);
     $question_models = $connection->createCommand($sql . " LIMIT :offset,:limit");
     $question_models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $question_models->bindValue(':limit', $pages->pageSize);
     $question_models = $question_models->queryAll();
     $this->render('index', array('count' => $count, 'question_models' => $question_models, 'pages' => $pages, 'word' => $word));
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:21,代码来源:SearchController.php

示例6: actionIndex

 /**
  * 显示主页
  * @param String $order
  */
 public function actionIndex($order = "new")
 {
     //根据不同的order 选择不同的sql语句
     switch ($order) {
         case 'new':
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) order by `{{question}}`.`add_time` desc\n\t\t\t\t";
             break;
             //热门查看人数排序
         //热门查看人数排序
         case 'hot':
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`\n\t\t\t\t,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) order by `{{question}}`.`view_count` desc\n\t\t\t\t";
             break;
             //未回复数排序
         //未回复数排序
         case 'unresponsive':
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`\n\t\t\t\t,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) where `{{question}}`.`answer_count` = 0\n\t\t\t\t";
             break;
             //默认根据时间排序
         //默认根据时间排序
         default:
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`\n\t\t\t\t,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) order by `{{question}}`.`add_time` desc\n\t\t\t\t";
             break;
     }
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $models = $connection->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $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();
     //获取话题
     $topic_models = Topic::model()->findAll(array('select' => 'id,topic_title', 'order' => 'discuss_count desc', 'limit' => '25'));
     $this->pageTitle = "首页";
     $this->render('index', array('models' => $models, 'pages' => $pages, 'topic_models' => $topic_models));
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:43,代码来源:SiteController.php

示例7: actionSharecontact

 public function actionSharecontact()
 {
     $organID = Commonmodel::getOrganID();
     $dealer = Dealer::model()->find('userID=:userid', array(':userid' => $organID));
     $share = BusinessShare::model()->findAll('InitiatorID=:intorID and Status=2', array(':intorID' => $organID));
     foreach ($share as $key => $value) {
         $shareID .= ',' . $value['ShareID'];
     }
     $shareID = ltrim($shareID, ",");
     //查出shareID
     $sql = "select a.id,a.contact_user_id,a.customertype,\n\t\t   a.cooperationtype,a.name,a.sex,\n\t\t   a.companyname,a.phone,a.province,a.city,a.area,a.email,\n\t\t   a.weixin,a.QQ,a.create_time,a.Status,a.jiapart_ID,a.update_time,\n\t\t   (select b.category from tbl_customer_category b where a.customercategory=b.id and a.user_id={$organID}) as customercategory\n\t\t   from tbl_business_contacts a where \n\t\t   user_id='{$organID}' and Status=0  and a.contact_user_id in({$shareID})";
     if ($_POST) {
         $search['name'] = $_POST['name'];
         $search['phone'] = $_POST['phone'];
         $search['keyword'] = $_POST['keyword'];
         if ($search) {
             if ($search['name']) {
                 $sql .= " and name like'%{$search['name']}%'";
             }
             if ($search['phone']) {
                 $sql .= " and phone like '%{$search['phone']}%'";
             }
             if ($search['keyword']) {
                 $sql .= " and (companyname like '%{$search['keyword']}%') ";
             }
         }
     }
     $sql .= "order by create_time desc";
     $criteria = new CDbCriteria();
     $models = Yii::app()->db->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = intval($_GET['rows']);
     $pages->applylimit($criteria);
     $models = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $models->bindValue(':limit', $pages->pageSize);
     $models = $models->queryAll();
     foreach ($models as $key => $value) {
         $data[$key]['id'] = $value['id'];
         $data[$key]['Initiator'] = F::msubstr($dealer['organName']);
         $data[$key]['companyID'] = $value['contact_user_id'];
         //$data[$key]['customertype'] = $value['customertype'];
         $data[$key]['cooperationtype'] = $value['cooperationtype'];
         $data[$key]['customercategory'] = $value['customercategory'];
         $data[$key]['name'] = $value['name'];
         $data[$key]['sex'] = $value['sex'];
         $data[$key]['companyname2'] = F::msubstr($value['companyname']);
         $data[$key]['companyname'] = $value['companyname'];
         $data[$key]['phone'] = $value['phone'];
         $data[$key]['province'] = $value['province'];
         $data[$key]['city'] = $value['city'];
         $data[$key]['area'] = $value['area'];
         $data[$key]['address'] = F::msubstr(Area::getCity($value['province']) . Area::getCity($value['city']) . Area::getCity($value['area']));
         $data[$key]['email'] = $value['email'];
         $data[$key]['weixin'] = $value['weixin'];
         $data[$key]['QQ'] = $value['QQ'];
         $data[$key]['create_time'] = $value['create_time'];
         $data[$key]['Status'] = $value['Status'];
         $data[$key]['jiapart_ID'] = $value['jiapart_ID'];
         $data[$key]['update_time'] = $value['update_time'];
         //$data[$key]['checked']=true;
     }
     $rs = array('total' => $count, 'rows' => !empty($data) ? $data : array());
     echo json_encode($rs);
 }
开发者ID:zwq,项目名称:unpei,代码行数:66,代码来源:ContactController.php

示例8: getAll

 public static function getAll($params, &$pages, &$comLists)
 {
     $sql = $params['sql'];
     if (!$sql) {
         return false;
     }
     $pageSize = $params['pageSize'];
     $_size = isset($pageSize) ? $pageSize : 30;
     $com = Yii::app()->db->createCommand($sql)->query();
     //添加限制,最多取1000条记录
     //todo,按不同情况分不同最大条数
     $total = $com->rowCount > 1000 ? 1000 : $com->rowCount;
     $pages = new CPagination($com->rowCount);
     $criteria = new CDbCriteria();
     $pages->pageSize = $_size;
     $pages->applylimit($criteria);
     $com = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $com->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $com->bindValue(':limit', $pages->pageSize);
     $comLists = $com->queryAll();
 }
开发者ID:ph7pal,项目名称:naodong,代码行数:21,代码来源:Posts.php

示例9: actionMessage

 public function actionMessage($m)
 {
     $uid = Yii::app()->session['uid'];
     $data['uid'] = $uid;
     $sql = "select * from {{icontact}} where userid = {$uid} ";
     switch ($m) {
         case 2:
             break;
         case 1:
             $sql .= " and isread = 1 ";
             break;
         case 0:
             $sql .= " and isread = 0 ";
             break;
     }
     $order = " order by time desc ";
     $sql .= $order;
     $criteria = new CDbCriteria();
     $model = Yii::app()->db->createCommand($sql)->queryAll();
     $pages = new CPagination(count($model));
     $pages->pageSize = 7;
     $pages->applylimit($criteria);
     $model = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $model->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $model->bindValue(':limit', $pages->pageSize);
     $commentInfo = $model->queryAll();
     $data['pages'] = $pages;
     $data['messageInfo'] = $commentInfo;
     $this->render("imessage", $data);
 }
开发者ID:returncn,项目名称:chen-xia-cms,代码行数:30,代码来源:AdminController.php

示例10: actionArticles

 public function actionArticles()
 {
     $uid = Yii::app()->session['uid'];
     $sql = "select b.*,l.label from {{blog}} b,{{label}} l where b.userid = {$uid} and b.labelid = l.id order by b.time desc ";
     $criteria = new CDbCriteria();
     $model = Yii::app()->db->createCommand($sql)->queryAll();
     $pages = new CPagination(count($model));
     $pages->pageSize = 7;
     $pages->applylimit($criteria);
     $model = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $model->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $model->bindValue(':limit', $pages->pageSize);
     $blogs = $model->queryAll();
     $data['pages'] = $pages;
     $data['blogs'] = $blogs;
     $this->render('articles', $data);
     //			$criteria = new CDbCriteria();		//AR的另一种写法
     //			$criteria->condition = "userid=".Yii::app()->session['uid'];
     //			$blogs = new Blog();
     //			$total = $blogs->count($criteria);	//统计条数
     //
     //			$pager = new CPagination($total);
     //			$pager->pageSize = 7;
     //			$pager->applyLimit($criteria);
     //			$blogs = $blogs->findAll($criteria);
     //			$data = array('pages'=>$pager,'blogs'=>$blogs);
     //			$this->render('articles',$data);
 }
开发者ID:biggtfish,项目名称:A-Simple-CMS,代码行数:28,代码来源:ArticleController.php

示例11: actionArticles

 public function actionArticles()
 {
     $uid = Yii::app()->session['uid'];
     $sql = "select b.*,l.label from {{blog}} b,{{label}} l where b.userid = {$uid} and b.labelid = l.id order by b.time desc ";
     $criteria = new CDbCriteria();
     $model = Yii::app()->db->createCommand($sql)->queryAll();
     $pages = new CPagination(count($model));
     $pages->pageSize = 7;
     $pages->applylimit($criteria);
     $model = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $model->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $model->bindValue(':limit', $pages->pageSize);
     $blogs = $model->queryAll();
     $data['pages'] = $pages;
     $data['blogs'] = $blogs;
     $this->render('articles', $data);
 }
开发者ID:returncn,项目名称:chen-xia-cms,代码行数:17,代码来源:ArticleController.php


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