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


PHP ArticleModel::getArticlesByAdminId方法代码示例

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


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

示例1: index

 public function index()
 {
     $errors = $this->errors;
     R('Admin', 'setting');
     //实例化Model
     $articleModel = new ArticleModel();
     //文章
     $commentModel = new CommentModel();
     //评论
     $collectModel = new CollectModel();
     //文章收藏
     $adminModel = new AdminModel();
     //博主
     //博主信息
     $blogerInfo = $this->getBlogerInfo($_SESSION['admin']['adminId']);
     //获取所有文章分类
     $allTypes = $this->getAllTypes($_SESSION['admin']['adminId']);
     //获取所有文章标签
     $allTags = $this->getAllTags();
     //最新三条评论
     $latestComments = $this->getLatestComments($_SESSION['admin']['adminId'], '0,3');
     //var_dump($latestComments);exit;
     //用户个人信息
     $allUserInfo = $this->getAllUserInfo();
     //根据adminId获取文章
     $str = "";
     $p = isset($_GET['p']) ? $_GET['p'] : 1;
     $pagesize = 10;
     $curpage = ($p - 1) * $pagesize;
     $limit = $curpage . "," . $pagesize;
     //排序
     if (isset($_GET['order'])) {
         $order = str_replace('.', ' ', $_GET['order']);
     } else {
         $order = 'addTime desc';
     }
     //类型
     if (isset($_GET['typeId'])) {
         $typeId = $_GET['typeId'];
     } else {
         $typeId = '';
     }
     //根据adminId获取文章
     $articles = $articleModel->getArticlesByAdminId($_SESSION['admin']['adminId'], $limit, $order, $typeId);
     $count = $this->articleCount($_SESSION['admin']['adminId']);
     if ($count > $pagesize) {
         $page = new Page($count, $p, $pagesize);
         $str = $page->show('themeuk.php');
     }
     //文章总数
     $articlesArr = array();
     foreach ($articles as $key => $value) {
         //对tagId 进行处理
         if ($value['tagId']) {
             $value['tagId'] = explode(',', trim($value['tagId'], ','));
         }
         //查询评论数
         $value['commentCount'] = $commentModel->getCommentCountByArticleId($value['articleId']);
         //查询收藏数
         $value['collectCount'] = $collectModel->getCollectCountByArticleId($value['articleId']);
         $articlesArr[$value['articleId']] = $value;
     }
     $this->assign('page', $str);
     //分页
     $this->assign("articles", $articlesArr);
     //文章
     $this->assign('count', $count);
     $this->assign("allTags", $allTags);
     //所有文章标签
     $this->assign("allTypes", $allTypes);
     //某人所有文章分类
     $this->assign('blogerInfo', $blogerInfo);
     $this->assign('latestComments', $latestComments);
     //最新三条评论
     $this->assign('allUserInfo', $allUserInfo);
     //某用户信息
     $this->assign("pageTitle", "个人主页");
     $this->display();
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:79,代码来源:AdminCtrl.class.php

示例2: articleList

 public function articleList()
 {
     //获取博主Id
     //$_GET['blogerId'] = 1;//测试
     $blogerId = Data::get($_GET['blogerId'], Data::Int);
     //$blogerId =1;//测试
     if (!is_int($blogerId) && $blogerId <= 0) {
         R('Index', 'index');
     }
     //实例化Model
     $articleModel = new ArticleModel();
     //文章
     $commentModel = new CommentModel();
     //评论
     $collectModel = new CollectModel();
     //文章收藏
     //博主个人信息
     $blogerInfo = $this->getBlogerInfo($blogerId);
     //获取所有文章分类
     $allTypes = $this->getAllTypes($blogerId);
     //获取所有文章标签
     $allTags = $this->getAllTags();
     //最新三条评论
     $latestComments = $this->getLatestComments($blogerId, '0,3');
     //var_dump($latestComments);exit;
     //用户个人信息
     $allUserInfo = $this->getAllUserInfo();
     //var_dump($allTypes);exit;
     $str = "";
     $p = isset($_GET['p']) ? $_GET['p'] : 1;
     $pagesize = 10;
     $curpage = ($p - 1) * $pagesize;
     $limit = $curpage . "," . $pagesize;
     //排序
     if (isset($_GET['order']) && $_GET['order'] == "addTime.desc" || $_GET['order'] == "hitNum.desc") {
         $order = str_replace('.', ' ', $_GET['order']);
     } else {
         $order = 'addTime desc';
     }
     //类型
     if (isset($_GET['typeId'])) {
         $typeId = Data::get($_GET['typeId'], Data::Int);
     } else {
         $typeId = '';
     }
     // if(isset($_GET['tagId'])){
     // 	$tagId=Data::get($_GET['tagId'],Data::Int);
     // }else{
     // 	$tagId='';
     // }
     //根据adminId获取文章
     // if(isset($tagId) && !empty($tagId)){
     // 	$articles=$articleModel->getArticlesByTagId($limit,$order,$tagId);
     // }else{
     $articles = $articleModel->getArticlesByAdminId($blogerId, $limit, $order, $typeId, '');
     //}
     $count = $this->articleCount($blogerId);
     if ($count > $pagesize) {
         $page = new Page($count, $p, $pagesize);
         $str = $page->show('themeuk.php');
     }
     //$articles = formatkey($articles,'articleId');//设置articleId主键
     // echo "<pre>";var_dump($articles);echo "</pre>";
     // exit;
     $articlesArr = array();
     foreach ($articles as $key => $value) {
         //对tagId 进行处理
         if ($value['tagId']) {
             $value['tagId'] = explode(',', trim($value['tagId'], ','));
         }
         //查询评论数
         $value['commentCount'] = $commentModel->getCommentCountByArticleId($value['articleId']);
         //查询收藏数
         $value['collectCount'] = $collectModel->getCollectCountByArticleId($value['articleId']);
         //是否已收藏
         if ($_SESSION['qq']['userId']) {
             if ($collectModel->getCollects($value['articleId'], $_SESSION['qq']['userId'])) {
                 $value['if_collect'] = 1;
             }
         } else {
             $value['if_collect'] = 0;
         }
         $articlesArr[$value['articleId']] = $value;
     }
     //echo "<pre>";var_dump($articlesArr);echo "</pre>";exit;
     $this->assign('page', $str);
     //分页
     $this->assign("articles", $articlesArr);
     //文章
     $this->assign('count', $count);
     $this->assign("allTags", $allTags);
     //所有文章标签
     $this->assign("allTypes", $allTypes);
     //某人所有文章分类
     $this->assign('blogerInfo', $blogerInfo);
     $this->assign('latestComments', $latestComments);
     //最新三条评论
     $this->assign('allUserInfo', $allUserInfo);
     //某用户信息
     $this->assign("pageTitle", "个人主页");
//.........这里部分代码省略.........
开发者ID:Jnnock,项目名称:myyyk,代码行数:101,代码来源:IndexCtrl.class.php


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