使用AJAX和SQL监控数据库更新直播数据库、AJAX、SQL

2023-09-10 20:13:12 作者:﹏雨中漫步〆

一个人怎么可以在本地触发事件时,在连接数据库更改一个字段?我做了一些研究,但它好像有有不同和不确定的问题的答案。

How can one trigger an event locally when a field in a connected database changes? I've done some research but it seems like there there are varying and inconclusive answers to the question.

我要建一个应用程序,用户评价意见,我想有收视率的实时变化时,它们是由不同的用户修改。例如:用户A和B都是观看注释饲料。假设用户A uprates评论,引起了等级字段的注释行中我的数据库表进行递增。无需定期清爽的定时器,我想有用户B参见注释(更新他的网页)的变化,一旦A已经评了。有没有办法做到这一点只用PHP,SQL和JavaScript / jQuery的,或适用的插件/库?

I'm building an application where users rate comments, and I'd like to have the ratings change live when they are modified by a different user. For example: users A and B are both viewing the comment feed. Say user A uprates a comment, causing the "rating" field for that comment's row in my database table to be incremented. Without having a timer for periodic refreshing, I'd like to have user B see the change in comment (updated on his page) as soon as A has rated it. Is there a way to do this using just PHP, SQL, and JavaScript/jQuery, or applicable plugins/libraries?

例子,思想,链接等所有AP preciated。感谢这么多的帮助。

Examples, ideas, links, etc. all appreciated. Thanks so much for the help.

推荐答案

该技术被称为彗星上的话Ajax的一出戏。有许多方法来完成它。在这里看到: http://en.wikipedia.org/wiki/Comet_(programming)

The technique is called Comet, a play on words to Ajax. There are many ways to accomplish it. See here: http://en.wikipedia.org/wiki/Comet_(programming)