MySQL表的事件监听器改变了吗? [英] Event listener for MySQL table change?

查看:951
本文介绍了MySQL表的事件监听器改变了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有php / javascript / mysql / ajax事件监听器或方法,每次MySQL表中的数据发生变化时都可以调用函数 - 例如添加新行或删除行时删除。 / p>

或者我从错误的角度看待它,我还在学习AJAX。



只是期待指向正确的方向,我找不到任何东西。谢谢。



编辑
基本上当用户坐在我的网站上时,如果新数据被添加到服务器上的数据库中从另一个来源(不是因为这个用户的动作),我希望能够调用一个函数异步加载该用户的新数据。

解决方案

如果您尝试根据MySQL中的其他更改更改MySQL中的日期,则触发器应该有效:



http://dev.mysql .com / doc / refman / 5.6 / en / triggers.html



如果您希望在数据输入时进行服务器端或客户端回调MySQL发生了变化,那么你将无法通过MySQL本身获得这种能力。您可能需要在架构中添加一些内容(标志,时间戳等),以指示何时更改数据,并根据数据更改运行异步进程以执行某些操作。


Is there a php/javascript/mysql/ajax event listener or method that can call a function each time the data in a MySQL table changes - such as when a new row is added, or a row changes/is deleted.

Or am I looking at it from the wrong perspective, I'm still learning AJAX.

Just looking to be pointed in the right direction, I couldn't find anything. Thanks.

Edit Basically when a user is sitting on my site, if new data is added to the database on the server from another source (not because of an action of this user), I want to be able to call a function to asynchronously load that new data for this user.

解决方案

If you are trying to change date in MySQL based on other changes in MySQL, triggers should work:

http://dev.mysql.com/doc/refman/5.6/en/triggers.html

If you are looking to have server-side or client-side callbacks when data in MySQL changes, then you won't have that ability via MySQL itself. You would likely need to add something to your schema (flags, timestamps, etc.) that indicate when data is changed and run asynchronous process to do something based on the change in data.

这篇关于MySQL表的事件监听器改变了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆