public function actionView($id) { $this->view_data['article'] = $article = Article::find()->where("id = {$id}")->asArray()->one(); //获取这篇文章的所有留言 $this->view_data['comments'] = Article::getComments($article['id']); return $this->render('view', $this->view_data); }
public function actionComments($article_id = 0) { if (Yii::$app->request->isAjax) { $comment_id = intval(Yii::$app->request->get('comment_id')); $comment = Comment::find()->where("id = {$comment_id}")->one(); $comment->status = Comment::STATUS_DELETE; $comment->save(); return json_encode(['errCode' => 0]); } $comments = Article::getComments($article_id); return $this->render('comments', ['comments' => $comments]); }