當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。