public function addalbumComment() { if (!$_SESSION['qq']) { $result['code'] = '021'; $result['message'] = '未登录,请登录账号!'; } else { //实例化model $commentModel = new CommentModel(); $albumModel = new AlbumModel(); $albumId = $_GET['albumId']; $content = $_GET['comment']; //根据相册id查询相册信息 $albumInfo = $albumModel->getAlbumById($albumId); $data = array('userId' => $_SESSION['qq']['userId'], 'albumId' => $albumId, 'content' => $content, 'adminId' => $albumInfo['adminId']); $commentId = $commentModel->addComment($data); if ($commentId) { $commentInfo = $commentModel->getCommentById($commentId); $result['code'] = '0'; $result['message'] = '恭喜,评论成功!'; $result['info'] = $commentInfo; } else { $result['code'] = '022'; $result['message'] = '抱歉,评论失败!'; } } echo json_encode($result); exit; }
public function addAlbumComment() { if (!$_SESSION['qq']) { $result['code'] = "021"; $result['message'] = "未登录,请登录账号!"; } else { $_POST['content'] = Data::filter($_POST['content'], 9); $_POST['albumId'] = Data::get($_POST['albumId'], Data::Int); $_POST['adminId'] = Data::get($_POST['adminId'], Data::Int); $_POST['userId'] = Data::get($_POST['userId'], Data::Int); $comment = new CommentModel(); $row = $comment->addComment($_POST); if ($row) { $comments = $comment->getCommentById($row); $result['info'] = $comments; $result['code'] = "0"; $result['message'] = "恭喜,评论成功!"; } else { $result['code'] = "022"; $result['message'] = "评论失败"; } } echo json_encode($result); exit; }