当前位置: 首页>>代码示例>>PHP>>正文


PHP CommentModel::insertComment方法代码示例

本文整理汇总了PHP中CommentModel::insertComment方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel::insertComment方法的具体用法?PHP CommentModel::insertComment怎么用?PHP CommentModel::insertComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommentModel的用法示例。


在下文中一共展示了CommentModel::insertComment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: publishAction

 /**
  * 发表评论
  * curl -d "course_id=1&comment_id=1&video_id=0&content=helloaaaaaaaaaa" http://182.92.110.119/comment/publish
  */
 function publishAction()
 {
     $courseId = (int) $this->post("course_id", 0);
     $commentId = (int) $this->post("comment_id", 0);
     $videoId = (int) $this->post("video_id", 0);
     $content = $this->post("content", "");
     $time = time();
     $comment = array("uid" => $this->uid, "comment_id" => $commentId, "course_id" => $courseId, "video_id" => $videoId, "content" => $content, "create_time" => $time);
     $commentModel = new CommentModel();
     $id = $commentModel->insertComment($comment);
     if ($id) {
         $userModel = new UserModel();
         $videoModel = new VideoModel();
         $courseModel = new CourseModel();
         $author = $userModel->getUser($comment['uid']);
         $comment['create_time_fmt'] = Common_Time::flow($comment['create_time']);
         $comment['author_uid'] = $author['stuff_id'];
         $comment['author_name'] = $author['stuff_name'];
         $comment['author_avator'] = $author['avator'];
         if ($comment['comment_id']) {
             $parentComment = $commentModel->getComment($comment['comment_id']);
             $beReplyAuthor = $userModel->getUser($parentComment['uid']);
             $parentComment['author_uid'] = $beReplyAuthor['stuff_id'];
             $parentComment['author_name'] = $beReplyAuthor['stuff_name'];
             $parentComment['author_avator'] = $beReplyAuthor['avator'];
             $parentComment['create_time_fmt'] = Common_Time::flow($parentComment['create_time']);
             $comment['parent_comment'] = $parentComment;
         }
         if ($comment['video_id']) {
             $section = $videoModel->getVideoBelongSection($comment['video_id']);
             if (!$section) {
                 $practiseModel = new PractiseModel();
                 $practise = $practiseModel->getVideoBelongPractise($comment['video_id'], $courseId);
                 $comment['practise_seq'] = $practise['seq'];
                 $section = $courseModel->getSection($practise['section_id']);
             }
             $chapter = $courseModel->getSection($section["parent_id"]);
             $comment["chapter_id"] = $chapter["id"];
             $comment["chapter_name"] = $chapter["name"];
             $comment["chapter_seq"] = $chapter["seq"];
             $comment["section_id"] = $section["id"];
             $comment["section_name"] = $section["name"];
             $comment["section_seq"] = $section["seq"];
             $userVideo = $videoModel->getUserVideoVote($comment['uid'], $comment['video_id']);
             $comment["video_like"] = isset($userVideo['like_type']) ? $userVideo['like_type'] : 0;
         }
         $this->displayJson(Common_Error::ERROR_SUCCESS, array($comment));
     }
     $this->displayJson(Common_Error::ERROR_MYSQL_EXECUTE);
 }
开发者ID:krisrita,项目名称:udo,代码行数:54,代码来源:Comment.php


注:本文中的CommentModel::insertComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。