简体   繁体   中英

PHP & MySQL: Check if table's data has changed without polling?

Is there a way to test if a MySQL table's data has changed at all , without connecting or querying.

This might sound weird, but in ASP.NET you can set up SqlDependencies that are kind of events that occur when data is changed (so you don't have to poll your database).

you can use a UDF inside of a trigger to send a message through a socket. if you can not develop your own udf then maybe a combination of sys_exec and telnet will do the trick.

but be careful and do a good exception handling ie socket timout.

Might not fit your solution (especially if the writer to the db is not in the same application space as the reader) but what if on insert, you set some application wide variable to a Last updated value.
Which avoids you polling the db directly, although, there may still be some polling of the application for that value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM