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


PHP Post::findAll方法代码示例

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


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

示例1: actionIndex

 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     $model = new Post();
     $criteria = new CDbCriteria();
     $condition = "1=1";
     $title = trim($this->_request->getParam('title'));
     $catalogId = intval($this->_request->getParam('catalogId'));
     $title && ($condition .= ' AND title LIKE \'%' . $title . '%\'');
     $catalogId && ($condition .= ' AND catalog_id= ' . $catalogId);
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $criteria->with = array('catalog');
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     //根据title,catelogId,titleAlias查询
     $pageParams = $this->buildCondition($_GET, array('title', 'catalogId'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     //推荐位
     $recom_list = RecommendPosition::model()->findAll('type=:type', array(':type' => $this->_type), array('order' => 'id'));
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'recom_list' => $recom_list));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:29,代码来源:PostController.php

示例2: actionShow

 /**
  * 查看专题
  */
 public function actionShow($name)
 {
     $specialModel = Special::model()->find('title_alias=:titleAlias', array('titleAlias' => CHtml::encode(strip_tags($name))));
     if (false == $specialModel) {
         throw new CHttpException(404, '专题不存在');
     }
     //更新浏览次数
     $specialModel->updateCounters(array('view_count' => 1), 'id=:id', array('id' => $specialModel->id));
     $specialPostModel = new Post();
     $criteria = new CDbCriteria();
     $criteria->addCondition('t.status_is=:status AND special_id=:specialId');
     $criteria->params = array('status' => 'Y', 'specialId' => $specialModel->id);
     $criteria->order = 't.id DESC';
     $bagecmsSpecialCount = $specialPostModel->count($criteria);
     $postPage = new CPagination($bagecmsSpecialCount);
     $postPage->pageSize = 10;
     $postPageParams = XUtils::buildCondition($_GET, array());
     $postPageParams['#'] = 'list';
     $postPage->params = is_array($postPageParams) ? $postPageParams : array();
     $criteria->limit = $postPage->pageSize;
     $criteria->offset = $postPage->currentPage * $postPage->pageSize;
     $specialPostList = $specialPostModel->findAll($criteria);
     $this->_seoTitle = empty($specialModel->seo_title) ? $specialModel->title . ' - ' . $this->_conf['site_name'] : $specialModel->seo_title;
     $tpl = empty($specialModel->tpl) ? 'show' : $specialModel->tpl;
     $data = array('specialShow' => $specialModel, 'specialPostList' => $specialPostList, 'bagecmsPagebar' => $postPage);
     $this->render($tpl, $data);
 }
开发者ID:bigbol,项目名称:ziiwo,代码行数:30,代码来源:SpecialController.php

示例3: _catalogList

 /**
  * 获取栏目内容数据
  *
  * @param array   $params
  * @return array  数组
  */
 protected function _catalogList($params = array())
 {
     $postModel = new Post();
     $postCriteria = new CDbCriteria();
     $condition = '1';
     if ($params['catalog']) {
         $condition .= ' AND t.catalog_id=:catalogId';
         $criteriaParams[':catalogId'] = intval($params['catalog']);
     }
     if ($params['keyword']) {
         $condition .= ' AND t.title=:title';
         $criteriaParams[':title'] = CHtml::encode(strip_tags($params['keyword']));
     }
     $condition .= " AND t.status_is='Y'";
     $postCriteria->condition = $condition;
     $postCriteria->params = $criteriaParams;
     $postCriteria->order = 't.id DESC';
     $postCriteria->with = 'catalog';
     $count = $postModel->count($postCriteria);
     $postPages = new CPagination($count);
     $postPages->pageSize = $params['pageSize'] > 0 ? $params['pageSize'] : 20;
     $pageParams = XUtils::buildCondition($_GET, array('catalog', 'keyword'));
     $postPages->params = is_array($pageParams) ? $pageParams : array();
     $postCriteria->limit = $postPages->pageSize;
     $postCriteria->offset = $postPages->currentPage * $postPages->pageSize;
     $bagecmsDataList = $postModel->findAll($postCriteria);
     $catalogArr = Catalog::item($params['catalog'], $this->_catalog);
     if ($catalogArr) {
         $this->_seoTitle = empty($catalogArr['catalog_name']) ? $this->_seoTitle : $catalogArr['catalog_name'];
         $bagecmsCatalogData = $catalogArr;
         $this->_seoKeywords = empty($catalogArr['seo_keywords']) ? $this->_seoKeywords : $catalogArr['seo_keywords'];
         $this->_seoDescription = empty($catalogArr['seo_description']) ? $this->_seoDescription : $catalogArr['seo_description'];
     }
     return array('bagecmsDataList' => $bagecmsDataList, 'bagecmsPagebar' => $postPages, 'bagecmsCatalogData' => $bagecmsCatalogData);
 }
开发者ID:bigbol,项目名称:ziiwo,代码行数:41,代码来源:PostController.php

示例4: actionIndex

 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl();
     $model = new Post();
     $criteria = new CDbCriteria();
     $condition = '1';
     $title = trim($this->_gets->getParam('title'));
     $titleAlias = trim($this->_gets->getParam('titleAlias'));
     $catalogId = intval($this->_gets->getParam('catalogId'));
     $title && ($condition .= ' AND title LIKE \'%' . $title . '%\'');
     $titleAlias && ($condition .= ' AND title_alias LIKE \'%' . $titleAlias . '%\'');
     $catalogId && ($condition .= ' AND catalog_id= ' . $catalogId);
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $criteria->with = array('catalog');
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = XUtils::buildCondition($_GET, array('title', 'catalogId', 'titleAlias'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:29,代码来源:PostController.php

示例5: get

 /**
  * Gets a list of posts
  *
  * @param Request $request
  * @param string $params
  * @return void
  */
 protected static function get($request, $params)
 {
     try {
         $posts = Post::query($request->get('queryParams'), $request->include);
     } catch (OutOfBoundsException $e) {
         $posts = Post::findAll($request->include);
     }
     static::response($posts, 200);
 }
开发者ID:anehx,项目名称:blog,代码行数:16,代码来源:PostListController.class.php

示例6: run

 public function run()
 {
     $model = new Post();
     //条件
     $criteria = new CDbCriteria();
     $title = trim(Yii::app()->request->getParam('title'));
     $catalogId = intval(Yii::app()->request->getParam('catalogId'));
     $criteria->addColumnCondition(array('type' => $this->controller->_type));
     $title && $criteria->addSearchCondition('title', $title);
     $catalogId && $criteria->addColumnCondition(array('catalog_id' => $catalogId));
     $criteria->order = 't.id DESC';
     $criteria->with = array('catalog');
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:20,代码来源:IndexAction.php

示例7: actionIndex

 /**
  * 首页
  */
 public function actionIndex()
 {
     $keyword = CHtml::encode(strip_tags(trim($this->_gets->getParam('keyword'))));
     $postModel = new Post();
     $postCriteria = new CDbCriteria();
     if ($keyword) {
         $postCriteria->addSearchCondition('t.title', $keyword);
     }
     $postCriteria->addCondition('t.status_is=:status');
     $postCriteria->params[':status'] = 'Y';
     $postCriteria->with = 'catalog';
     $postCriteria->order = 't.id DESC';
     $bagecmsQuestionCount = $postModel->count($postCriteria);
     $postPages = new CPagination($bagecmsQuestionCount);
     $postPages->pageSize = 15;
     $postPageParams = XUtils::buildCondition($_GET, array('keyword'));
     $postPageParams['#'] = 'list';
     $postPages->params = is_array($postPageParams) ? $postPageParams : array();
     $postCriteria->limit = $postPages->pageSize;
     $postCriteria->offset = $postPages->currentPage * $postPages->pageSize;
     $postList = $postModel->findAll($postCriteria);
     $this->render('index', array('bagecmsDataList' => $postList, 'bagecmsPagebar' => $postPages));
 }
开发者ID:bigbol,项目名称:ziiwo,代码行数:26,代码来源:SearchController.php

示例8: index

 function index()
 {
     $this->vars['posts'] = Post::findAll('Post', array('orderBy' => 'created_at desc'));
 }
开发者ID:jpic,项目名称:Jetfuel,代码行数:4,代码来源:PostsController.php


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