我们如何使用php检测数据库表中的更新或插入?

A database table's been updated by a person A with status_id,status_text,timedate etc (like facebook status). Another person B comments on that status, Both persons A and B are online. How would person A will be notified(like in facebook). Means how can we know the change in database table. any way through witch table trigger out side the database(Notification like in facebook). Any solution or clue will be appreciated.

1) Wrap database operations in an own class with corresponding methods, then you have full control over the database operations. When you call the method to add a comment, you can also add a notification in the same method. 2) You can save notifications in an own database and show them by page re-loading. You can even go further and make a polling to the server to render a certain section only via AJAX.

I guess an easy'ish way would be to have a last_updated column and look for the rows where that column is greater than last time you checked, or greater than the greatest you found last time.

Then if you use AJAX and polling or something you could keep track of that time in a session or just on the client.

AJAX will be imperative unless you want the page to reload at some set interval. Check for an update periodically depending on how much load you want to place on the server. Pull the data to the page and voila.