doula2426 2015-03-07 14:05
浏览 35
已采纳

如何使用PHP跟踪数据库表中的更新?

I want to ask is there a way to track database table using php mysql. I want to do something like i have a table called post. Now when user post some data other user need to view this data. That is latest one need to be view to user on the top. We can do this by refreshing div after every few sec or using ajax. But can we use Trigger. As we know it automatically fires when something is executed. Hence i want to know can we use trigger in PHP code to automatically detect changes in table. And when a new post is available it needs to return the data from database. Please give me a brief description about this. Thank you in advance.

  • 写回答

2条回答 默认 最新

  • dongmeng4742 2015-03-07 14:13
    关注

    The trigger is executed on Mysql Server, not on the PHP one (even if those are both on the same machine).

    So, I would say this is not quite possible -- at least not simply.

    Still, considering this entry from the MySQL FAQ on Triggers :

    23.5.11: Can triggers call an external application through a UDF?

    Yes. For example, a trigger could invoke the sys_exec() UDF available at MySQL Forge here: http://forge.mysql.com/projects/project.php?id=211

    So, there might be a waty, actually, via an UDF function that would launch the php executable/script ; not that easy, but seems possible ;-)

    Read more about it in:

    https://stackoverflow.com/a/1467387/3653989

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

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流