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


PHP Posts::getAll方法代码示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     $type = zmf::val('type', 1);
     if (!$type || $type == 'staycheck') {
         $status = Posts::STATUS_STAYCHECK;
     } else {
         $status = Posts::STATUS_PASSED;
     }
     $sql = "SELECT c.id,c.uid,c.content,c.cTime,p.title,c.logid,c.status FROM {{comments}} c,{{posts}} p WHERE c.status={$status} AND c.logid=p.id ORDER BY c.cTime DESC";
     Posts::getAll(array('sql' => $sql), $pager, $items);
     if (!empty($items)) {
         $uids = array_filter(array_keys(CHtml::listData($items, 'uid', '')));
         $uidsStr = join(',', $uids);
         if ($uidsStr != '') {
             $usernames = Yii::app()->db->createCommand("SELECT id,truename FROM {{users}} WHERE id IN({$uidsStr})")->queryAll();
             if (!empty($usernames)) {
                 foreach ($items as $k => $val) {
                     foreach ($usernames as $val2) {
                         if ($val['uid'] > 0 && $val['uid'] == $val2['id']) {
                             $items[$k]['loginUsername'] = $val2['truename'];
                         }
                     }
                 }
             }
         }
     }
     $this->render('index', array('pages' => $pager, 'posts' => $items));
 }
开发者ID:ph7pal,项目名称:momo,代码行数:28,代码来源:CommentsController.php

示例2: actionNotice

 public function actionNotice()
 {
     $sql = "SELECT * FROM {{notification}} WHERE uid='{$this->uid}' ORDER BY cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $comLists);
     Notification::model()->updateAll(array('new' => 0), 'uid=:uid', array(':uid' => $this->uid));
     $data = array('posts' => $comLists, 'pages' => $pages);
     $this->pageTitle = $this->userInfo['truename'] . '的提醒 - ' . zmf::config('sitename');
     $this->render('notice', $data);
 }
开发者ID:ph7pal,项目名称:momo,代码行数:9,代码来源:UsersController.php

示例3: actionMap

 public function actionMap()
 {
     $this->layout = 'common';
     $sql = "SELECT id,title,lat,`long`,comments,favorite,cTime FROM {{posts}} WHERE lat!='' AND `long`!='' AND `status`=1 ORDER BY cTime ASC";
     Posts::getAll(array('sql' => $sql, 'pageSize' => 100), $pages, $posts);
     foreach ($posts as $k => $val) {
         $posts[$k]['href'] = Yii::app()->createUrl('posts/view', array('id' => $val['id']));
         $posts[$k]['cTime'] = zmf::formatTime($val['cTime']);
     }
     $posts = !empty($posts) ? $posts : array();
     $data = array('postJson' => CJSON::encode($posts), 'loadMap' => empty($posts) ? false : true);
     $this->pageTitle = '足迹 - ' . zmf::config('sitename');
     $this->selectNav = 'map';
     $this->render('/index/map', $data);
 }
开发者ID:ph7pal,项目名称:momo,代码行数:15,代码来源:IndexController.php

示例4: actionIndex

 public function actionIndex()
 {
     $this->poiType = zmf::filterInput($_GET['type']);
     $this->poiOrder = zmf::filterInput($_GET['order']);
     $areaid = zmf::filterInput($_GET['areaid']);
     if (!$this->poiOrder || !in_array($this->poiOrder, array('1', '2'))) {
         $this->poiOrder = '1';
     }
     $where = $order = '';
     if ($areaid) {
         $extra = Area::getAreaInfo($areaid);
         $areaIds = $extra['areaIds'];
         $areaInfo = $extra['areaInfo'];
         if ($areaIds) {
             $where .= " areaid IN({$areaIds}) AND ";
         }
     }
     $_typename = Position::exClassify($this->poiType);
     if ($this->poiType && $_typename && !is_array($_typename)) {
         $where .= " classify='{$this->poiType}' AND ";
     } else {
         $this->poiType = '';
         $_typename = '的景点、酒店、餐厅及购物';
     }
     if ($this->poiOrder == '1') {
         $order = ' ORDER BY score DESC';
     } elseif ($this->poiOrder == '2') {
         $order = ' ORDER BY scorer DESC';
     }
     //获取景点列表
     $sql = "SELECT id,title_cn,title_en,title_local,address_cn,address_en,address_local,score,scorer,attach,lat,`long`,faceimg,classify FROM {{position}} WHERE {$where} forWedding=1 AND status=" . Posts::STATUS_PASSED . $order;
     Posts::getAll(array('sql' => $sql), $pages, $posts);
     //获取所有受推荐地区
     $areas = Area::getTops(0);
     //面包屑
     $breads[] = CHtml::link('目的地', array('position/index'));
     if ($areaInfo) {
         $breads[] = $areaInfo['title'];
     }
     //页面SEO
     $this->pageTitle = '目的地 - ' . zmf::config('sitename');
     $this->render('index', array('posts' => $posts, 'pages' => $pages, 'areas' => $areas, 'breads' => $breads, 'areaId' => $areaid));
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:43,代码来源:PositionController.php

示例5: actionView

 public function actionView($id)
 {
     $id = zmf::filterInput($id);
     if (!$id || !is_numeric($id)) {
         throw new CHttpException(404, '你所查看的页面不存在.');
     }
     $info = Naodong::model()->findByPk($id);
     if ($info == NULL) {
         throw new CHttpException(404, '你所查看的页面不存在.');
     }
     //更新访问次数
     Posts::updateCount($id, 'Naodong');
     //获取评论列表
     $sql = "SELECT * FROM {{comments}} WHERE logid='{$id}' AND classify='naodong' AND status=" . Posts::STATUS_PASSED . " ORDER BY cTime ASC";
     Posts::getAll(array('sql' => $sql, 'pageSize' => 2), $pages, $comLists);
     //获取上下篇
     $preInfo = Naodong::model()->find(array('condition' => 'id>:id AND status=' . Posts::STATUS_PASSED, 'select' => 'id,title', 'params' => array(':id' => $id)));
     $nextInfo = Naodong::model()->find(array('condition' => 'id<:id AND status=' . Posts::STATUS_PASSED, 'select' => 'id,title', 'params' => array(':id' => $id)));
     $authorInfo = $recommends = array();
     if ($info['uid']) {
         //获取作者信息
         $authorInfo = Users::getUserInfo($info['uid']);
         //获取作者相关推荐
         $recommends = Naodong::getRecommends($info['uid'], $id);
     }
     //获取是否赞过
     if ($this->uid) {
         if (UserAction::checkAction($id, 'favorNaodong')) {
             $this->favored = true;
         }
     }
     $data = array('info' => $info, 'posts' => $comLists, 'pages' => $pages, 'userInfo' => $authorInfo, 'recommends' => $recommends, 'preInfo' => $preInfo, 'nextInfo' => $nextInfo);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->pageDescription = zmf::subStr($info['content'], 140);
     $this->mobileTitle = $authorInfo['truename'];
     $this->render('/index/view', $data);
 }
开发者ID:ph7pal,项目名称:naodong,代码行数:37,代码来源:IndexController.php

示例6: actionView

 public function actionView($id)
 {
     $this->layout = '/layouts/group';
     $this->currentModule = 'group';
     $info = WeddingGroup::model()->findByPk($id);
     if (!$info) {
         throw new CHttpException(404, '你所查看的页面不存在');
     }
     $info->avatar = $info->getAvatar($info->avatar);
     if (zmf::uid()) {
         $reInfo = GroupLink::findRelation($this->uid, $id);
         if ($reInfo) {
             $this->joined = true;
         }
     }
     //获取团队成员
     $criteria = new CDbCriteria(array('condition' => 'gl.groupid=' . $id, 'join' => 'LEFT JOIN {{group_link}} gl ON t.id=gl.uid', 'select' => 't.id,t.truename,t.avatar'));
     $members = new CActiveDataProvider('Users', array('pagination' => array('pageSize' => 10), 'criteria' => $criteria));
     //获取团队案例列表
     $sql = "SELECT p.id,p.title,p.faceimg,p.uid,p.colid,p.cTime,p.updateTime FROM {{posts}} p WHERE p.groupid='{$id}' AND p.classify=" . Posts::CLASSIFY_WEDDING . " AND p.status=" . Posts::STATUS_PASSED . " ORDER BY p.cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $posts);
     if (!empty($posts)) {
         foreach ($posts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $posts[$k]['faceimg'] = $_url;
             } else {
                 $posts[$k]['faceimg'] = '';
             }
         }
     }
     $data = array('info' => $info, 'posts' => $posts, 'pages' => $pages);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('view', $data);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:36,代码来源:GroupController.php

示例7: actionFavors

 /**
  * 用户关注列表
  */
 public function actionFavors()
 {
     $sql = "SELECT logid FROM {{favorites}} WHERE uid='{$this->uid}' AND classify='user' ORDER BY cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $comLists);
     $lists = array();
     if (!empty($comLists)) {
         foreach ($comLists as $uid) {
             $lists[] = Users::getUserInfo($uid['logid']);
         }
     }
     $data = array('posts' => $lists, 'pages' => $pages, 'from' => 'favors');
     $this->pageTitle = $this->userInfo['truename'] . '的关注列表 - ' . zmf::config('sitename');
     $this->render('favorites', $data);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:17,代码来源:UsersController.php

示例8: actionFavorites

 public function actionFavorites()
 {
     $sql = "SELECT * FROM {{favorites}} WHERE uid='{$this->uid}' AND classify!='user' ORDER BY cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $lists);
     if (!empty($lists)) {
         foreach ($lists as $k => $v) {
             $type = $v['classify'];
             $_info = '';
             $_url = '';
             switch ($type) {
                 case 'posts':
                     $_info = Posts::getSimpleInfo(array('keyid' => $v['logid'], 'origin' => 'posts'));
                     $_url = Yii::app()->createUrl('posts/index', array('id' => $v['logid']));
                     break;
                 case 'answer':
                     $_info = Posts::getSimpleInfo(array('keyid' => $v['logid'], 'origin' => 'answer'));
                     $_url = Yii::app()->createUrl('question/answer', array('id' => $v['logid']));
                     break;
                 case 'poipost':
                     $_info = Posts::getSimpleInfo(array('keyid' => $v['logid'], 'origin' => 'poipost'));
                     $_url = Yii::app()->createUrl('poipost/view', array('id' => $v['logid']));
                     break;
                 case 'poitips':
                     $_info = Posts::getSimpleInfo(array('keyid' => $v['logid'], 'origin' => 'poitips'));
                     $_url = '';
                     break;
             }
             if (!$_info) {
                 unset($lists[$k]);
                 continue;
             }
             $lists[$k]['data'] = $_info;
             $lists[$k]['url'] = $_url;
             $lists[$k]['classify'] = $type;
         }
     }
     $data = array('posts' => $lists, 'pages' => $pages);
     $this->pageTitle = $this->userInfo['username'] . '的收藏 - ' . zmf::config('sitename');
     $this->render('favorites', $data);
 }
开发者ID:ph7pal,项目名称:mei,代码行数:40,代码来源:UsersController.php

示例9: actionIndex

 public function actionIndex()
 {
     $this->pType = zmf::filterInput($_GET['type']);
     $this->pOrder = zmf::filterInput($_GET['order']);
     $areaid = zmf::filterInput($_GET['areaid']);
     $colid = zmf::filterInput($_GET['colid']);
     $tagid = zmf::filterInput($_GET['tagid']);
     if (!$this->pOrder || !in_array($this->pOrder, array('1', '2'))) {
         $this->pOrder = '1';
     }
     $where = $order = $areaInfo = '';
     if ($areaid) {
         $extra = Area::getAreaInfo($areaid);
         $areaIds = $extra['areaIds'];
         $areaInfo = $extra['areaInfo'];
         if ($areaIds) {
             $where .= " p.areaid IN({$areaIds}) AND ";
         }
     }
     if ($colid) {
         $where .= " p.colid='{$colid}' AND ";
         $this->selectColid = $colid;
     }
     if ($this->pOrder == '1') {
         $order = ' ORDER BY p.cTime DESC';
     } elseif ($this->pOrder == '2') {
         $order = ' ORDER BY p.hits DESC';
     }
     if ($tagid) {
         $sql = "SELECT p.id,p.title,p.faceimg,p.uid,p.colid,p.cTime,p.updateTime FROM {{posts}} p,{{tag_relation}} tr WHERE tr.tagid='{$tagid}' AND tr.classify='posts' AND tr.logid=p.id AND {$where} p.classify=" . Posts::CLASSIFY_WEDDING . " AND p.status=" . Posts::STATUS_PASSED . $order;
     } else {
         $sql = "SELECT p.id,p.title,p.faceimg,p.uid,p.colid,p.cTime,p.updateTime FROM {{posts}} p WHERE {$where} p.classify=" . Posts::CLASSIFY_WEDDING . " AND p.status=" . Posts::STATUS_PASSED . $order;
     }
     Posts::getAll(array('sql' => $sql), $pages, $posts);
     if (!empty($posts)) {
         foreach ($posts as $k => $p) {
             $posts[$k]['coltitle'] = '';
             if ($p['colid']) {
                 $coltitle = Column::getOne($p['colid'], 'title');
                 if ($coltitle) {
                     $posts[$k]['coltitle'] = $coltitle;
                 }
             }
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $posts[$k]['faceimg'] = $_url;
             } else {
                 $posts[$k]['faceimg'] = '';
             }
         }
     }
     //面包屑
     $breads[] = CHtml::link('作品集', array('posts/index'));
     if ($areaInfo) {
         $breads[] = $areaInfo['title'];
     }
     //获取所有受推荐地区
     $areas = Area::getTops(0);
     //文章分类
     $cols = Column::allCols(1, 0, 1, Posts::CLASSIFY_WEDDING);
     //推荐的标签
     $suggestTags = Tags::getTops('posts');
     $data = array('posts' => $posts, 'pages' => $pages, 'breads' => $breads, 'areas' => $areas, 'areaId' => $areaid, 'cols' => $cols, 'tags' => $suggestTags, 'tagid' => $tagid);
     $this->pageTitle = '作品集 - ' . zmf::config('sitename');
     $this->render('all', $data);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:67,代码来源:PostsController.php


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