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(); }