Jump to content


Photo

MySQL db watcher


  • Please log in to reply
3 replies to this topic

#1 bg1982

bg1982
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 October 2006 - 04:00 AM

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.

#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 26 October 2006 - 04:30 AM

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.

#3 bg1982

bg1982
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 October 2006 - 04:45 AM

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.


#4 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 26 October 2006 - 07:34 AM

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

What I was suggesting was to have something like

mysql_query("UPDATE ... ");
touch("/tmp/database_is_updated");

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users