I have, at its heart, a php/mysql application. Every ~15 minutes new data is added to the database. I want to notify users that new data is in the database.
I was thinking of having some JS run on the clients computer to check for updates every 60 seconds, but I don’t want to pull down the results unless something has actually changed/been added in the DB.
So my question is: using PHP/JS/MYSQL what is the best way for clients to detect new rows in the DB?
One possible solution I was kicking around was having a seperate table called “switch” with a BOOL called ‘switch’, and everytime I update the DB setting “switch” to true for 60 seconds. Then the client computers check to see if switch.switch = ‘1’ (true) every 60 seconds.
Thoughts? I’m open to suggestions on any part of this plan? I do have the jQuery library loaded if anyone wants to make a jQuery suggestion…
Instead of your “switch” just being a flag, have it be a version number. Increment the number whenever you put new stuff in the database. Then the clients just compare their number with the one they fetch periodically, and when the numbers are different they know it’s time for an update. (Obviously they remember the new number for the next test …)