Jump to content

MySQL db watcher


bg1982

Recommended Posts

I am trying to make my webpage refresh whenever I have a new record entered to the database with a predefined threshold, it's like filesystem watcher, but here I want to watch a specific table with a specific field.

what I know that we can use file system watcher using VB.Net and watch the database files for change, but that would be very generic and any change in the database would refresh the page.

any idea.
thanks.
Link to comment
Share on other sites

You could do it ajax style, and use javascript to poll regularly.  For example, every 10 seconds you could send a request to a php script which returns "Yes" if there's another record, or "No" otherwise.

Or, building on the file system watcher, you could have the process which creates the new database record also create a file (or update a file).  Then your file system watcher can be triggered.
Link to comment
Share on other sites

Thanks for the idea, but my application is very time sensitive we are talking milliseconds... and concerning the filesystem watcher, as I understood you want me to watch the table file in the database directory, but this will trigger my webpage anytime any change happened to my database, where what I am looking for is a specific field with specific value.
Link to comment
Share on other sites

Milliseconds?  I guess polling isn't going to work then.

What I was suggesting was to have something like

[code]mysql_query("UPDATE ... ");
touch("/tmp/database_is_updated");[/code]

The idea being to actively create/modify a file to indicate that an update has happened.  It could also be done with a trigger depending on your DBMS.  If you can have a trigger which modifies a file whenever the specific field is updated, and a file system watcher which notices that, then that file can be a method of signalling the watcher that a change has occurred.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.