當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArticleModel::getArticleById方法代碼示例

本文整理匯總了PHP中ArticleModel::getArticleById方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArticleModel::getArticleById方法的具體用法?PHP ArticleModel::getArticleById怎麽用?PHP ArticleModel::getArticleById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArticleModel的用法示例。


在下文中一共展示了ArticleModel::getArticleById方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 public function index()
 {
     //var_dump($_SESSION['qq']);
     $articleId = $_GET['articleId'];
     $article = new ArticleModel();
     $content = $article->getArticleById($articleId);
     $collect = new CollectModel();
     $comment = new CommentModel();
     $commentNum = $comment->getCommentCountByArticleId($articleId);
     $content['commentNum'] = $commentNum;
     if ($this->isLogin()) {
         if ($collect->getCollects($article, $_SESSION['qq']['userId'])) {
             $this->assign('collects', '已收藏');
         } else {
             $collectNum = $collect->getCollectCountByuserId($article);
             $this->assign('collectNum', $collectNum);
             $this->assign('collects', '收藏');
         }
     }
     $this->assign('article', $content);
     //評論查詢
     $comments = $comment->getComment($articleId);
     $user = new UserModel();
     $arr = array();
     foreach ($comments as $key => $val) {
         $val[$key]['user'] = $user->getUserById($val['userId']);
     }
     $this->assign('comments', $comments);
     $this->display();
 }
開發者ID:Jnnock,項目名稱:myyyk,代碼行數:30,代碼來源:ArticleCtrl.class.php

示例2: index

 public function index()
 {
     //header('content-type:text/html;charset=utf-8');
     $userId = $_SESSION['qq']['userId'];
     $collect = new CollectModel();
     //查詢收藏
     $user_collect = $collect->getCollectByuserId($userId);
     $article = new ArticleModel();
     $arr = array();
     foreach ($user_collect as $v) {
         //根據收藏的文章id查詢文章
         $a = $article->getArticleById($v['articleId']);
         //取出admin的昵稱
         $a['adminName'] = $this->getAdmin($a['adminId']);
         $arr[] = $a;
     }
     $comment = new CommentModel();
     $commentAlbum = $comment->getCommentByAlbum($userId);
     $album = new AlbumModel();
     $articles = array();
     $albums = array();
     foreach ($commentAlbum as $v) {
         if ($v['albumId'] != null) {
             $c = $album->getAlbumById($v['albumId']);
             $c['adminName'] = $this->getAdmin($v['adminId']);
             $albums[] = $c;
         }
     }
     $commentArticle = $comment->getCommentByArticle($userId);
     foreach ($commentArticle as $v) {
         if ($v['articleId'] != null) {
             $a = $article->getArticleById($v['articleId']);
             $a['adminName'] = $this->getAdmin($v['adminId']);
             $articles[] = $a;
         }
     }
     var_dump($albums);
     $this->assign('user', $_SESSION['qq']['userName']);
     //評論過的相冊
     $this->assign('albums', $albums);
     //評論過的文章
     $this->assign('articles', $articles);
     //收藏
     $this->assign('user_collect', $arr);
     $this->display();
 }
開發者ID:Jnnock,項目名稱:myyyk,代碼行數:46,代碼來源:UserCtrl.class.php

示例3: getArticleById

 public function getArticleById()
 {
     $errors = $this->errors;
     $articleId = $_GET['articleId'];
     //實例化Model
     $adminModel = new AdminModel();
     //博主
     $articleModel = new ArticleModel();
     //文章
     $articleTypeModel = new ArticleTypeModel();
     //文章分類
     $articleTagModel = new ArticleTagModel();
     //文章標簽
     $commentModel = new CommentModel();
     //評論
     $collectModel = new CollectModel();
     //文章收藏
     //獲取所有文章分類
     $allTypes = $articleTypeModel->getCatrgoryByAdminId($_SESSION['admin']['adminId']);
     $allTypes = formatkey($allTypes, 'typeId');
     //設置typeId主鍵
     //獲取所有文章標簽
     $allTags = $articleTagModel->getArticleTag();
     $allTags = formatkey($allTags, 'tagId');
     //設置typeId主鍵
     $articleInfo = $articleModel->getArticleById($articleId);
     if ($articleInfo['tagId']) {
         $articleInfo['tagId'] = explode(',', trim($value['tagId'], ','));
     }
     //查詢評論數
     $articleInfo['commentCount'] = $commentModel->getCommentCountByArticleId($articleId);
     //查詢收藏數
     $articleInfo['collectCount'] = $collectModel->getCollectCountByArticleId($articleId);
     //獲取最新的評論
     $comment = $commentModel->getComment($articleId, '0,2');
     //博主信息
     $adminInfo = $adminModel->getAdminById($_SESSION['admin']['adminId']);
     $this->assign("admin", $adminInfo);
     //文章
     $this->assign("article", $articleInfo);
     //文章
     $this->assign("allTags", $allTags);
     //所有文章標簽
     $this->assign("allTypes", $allTypes);
     //某人所有文章分類
     $this->assign("comment", $comment);
     //某人所有文章分類
 }
開發者ID:Jnnock,項目名稱:myyyk,代碼行數:48,代碼來源:AdminCtrl.class.php


注:本文中的ArticleModel::getArticleById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。