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 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 three.js添加后处理以后模型锯齿化严重
  • ¥15 vite打包后,页面出现h.createElement is not a function,但本地运行正常