How does one create a PHP script that checks the MySQL row consistently and if a set query is matched, it starts an event, such as sending an email?
For example, on query match Fire start email:
To: me@me.com
From: php@trigger.com
Subject: Set query met, auto email complete.
It would be around MySQL5. I'm stuck on this. Am I best to do it in Perl or similar?
Perhaps it could also email various users? (This isn't the hard bit. :P)
解决方案
Using cron or similar scheduler involves polling, which works but is brute force and ignorance. I can't recommend it: there's a time delay between when the row changes and when cron executes the checking program; repeated checking is a waste of resources.
The elegant solution is database trigger, see Using Triggers and Can triggers call an external application through a UDF?. You will get an event whenever your table row is on fire or something, and your email sending program is called immediately.
If you want to use Perl, Email::Simple/Email::Sender is nifty.