CommentModel.inc 846 B

12345678910111213141516171819
  1. <?php
  2. class CommentModel {
  3. public function getComment($commentId) {
  4. $commentData = array();
  5. $sql = sprintf("SELECT c.comment_id, c.content, c.timestamp, c.url_name, c.is_edited, cpa.post_id as parent_post_id, cua.user_id as commenter_user_id, u.display_name as display_name, cca.parent_comment_id
  6. FROM comments c
  7. JOIN comment_user_associations cua ON c.comment_id = cua.comment_id
  8. JOIN comment_post_associations cpa ON c.comment_id = cpa.comment_id
  9. JOIN comment_comment_associations cca on c.comment_id = cca.comment_id
  10. JOIN users u ON cua.user_id = u.user_id
  11. WHERE c.comment_id = '%s'
  12. LIMIT 1", $commentId);
  13. $database = new Database();
  14. $queryResult = $database->query($sql);
  15. $commentData = $queryResult[0];
  16. $commentData['content'] = htmlspecialchars_decode($commentData['content']);
  17. return $commentData;
  18. }
  19. }