Reputation: 748
I am thinking of implementing a real time event listener for a personal project. Is there are way that say, if an INSERT
, UPDATE
, and DELETE
SQL queries have been issued, then mySQL will trigger a PHP file which will in turn process this, like refreshing a page automatically if a new record is found, or say a record has been edited or deleted?
I have been reading through mySQL triggers but I do not know how to implement. Thanks!
Upvotes: 1
Views: 4427
Reputation: 2152
If what you want to do is refreshing the page in an appropriately lazy manner, I suggest you look less to triggering out of MySQL and trigger it with AJAX. Waygood has a good link for the latter, but consider the former for simply updating data.
You can update the information on your site by way of long polling
. That way you keep a persistant connection open back to your server and can update data whenever the server pushes an update through. When done, simply start the connection again and wait for another update. The most commonly used LP technique is probably one with AJAX. Alternatively, for things like cross-domain support, you could go a bit more exotic with script tag long polling.
Upvotes: 1