doujia7162 2017-09-06 14:28
浏览 59

如何实现对评论的回复

I am wondering what is the best way to implement replies to a parent comment that are stacking infinitely.

Let's say my database looks like this:

Table               Columns
comments            comment_id | comment
comment_replies     comment_id | reply_to | comment

With this database, can I do this:

#1 Comment 1
       #2 Reply to #1
              #3 Reply to #2
                     #4 Reply to #3
                            ....
              #5 Reply to #3
                     #6 Reply to #5
                            ....

So far I have managed to do this for up to 1 reply by adding foreach comments.comment_id where is equal to comment_replies.reply_to. It works okay for up to 1 reply per a parent comment. Facebook reply system works the same way, but what if I want to add replies to other replies like in the example above?

  • 写回答

1条回答 默认 最新

  • dongzan0108 2017-09-06 14:32
    关注
    Table               Columns
    comments            comment_id | comment
    comment_replies     comment_id | reply_to | comment | isToReplay
    

    Change your table like this. If your reply for a comment make it false, if it for another reply make it true.

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)