douzhantanju1849 2009-06-08 19:40
浏览 62
已采纳

如何在发布应用程序时有多个回复?

this is a simple question.

With PHP and MySQL, I'm trying to build a bug reporting application.

Currently, the user can post bugs and a list of bugs is portrayed to the technician/administrator.

How do I make it so that many technician or administrators can reply to the report (thread?)

As in both mysql table layout and PHP coding?

The current MySQL table has layout of:

id          (Bug ID)
by          (person reporting it)
title       (Report Title)
content     (Contents of Report)
datetime    (Date/Time of report)
application (Application/page where problems happens)
priority    (Priority)
assigned    (Assigned To)
status      (Status of report/bug)

So no response column yet, but how do I achieve multiple post/responses with PHP and MySQLi?

Thanks

  • 写回答

3条回答 默认 最新

  • douren6035 2009-06-08 19:59
    关注

    What you usually do is you create a separate table for the responses. In that table you have one field that "points" to the first table. It could look like this:

    TABLE responses
    id         (Unique id)
    bug_id     ("Pointer" to which bug this response "belongs to")
    body       (Contents of response)
    

    This way you can have many responses which all point back to one bug, and thus you have virtually created an "ownership" or "relation". It is customary to call a relation like the one above a "one to many" if we pretend we're in the bugs table, looking out. (And a "many to one" of we're in the responses table, looking back at the bugs table.)

    Then, in PHP, when you want to retrieve all the responses belonging to a bug, you do something like this: (pseudo code)

    $bug = SELECT * FROM bugs WHERE id = $some_id
    $resps = SELECT * FROM responses WHERE bug_id = $bug['id'] ORDER BY created_at
    

    Voilá! Now you have the bug and all of its responses, ordered by creation date. When you insert new responses you need to set bug_id to the appropriate value, of course.

    Cheers!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?