How do I have a certain php script executed when the "deadline" according to the SQL is met?
The easiest I could explain this is by giving this simple example:
Imagine an eBay auction, which ends at let's say 5:00 pm, this is set as an SQL value for the auction entry. (I have all date/times in unixtime). Now, when the auction ends (the time hits 5:00 pm), the system sends an e-mail开发者_运维百科 to the winner, plus executes other many actions (specified inside a php file?).
How would I do this? I can write the php, etc, but I don't know how to make the 'site' execute it every time some auction ends?
I think I need to use CRON, but I'm not sure about it.
If you use CRON jobs then they will be fired after every fixed interval.. So here is the solution..
Make a CRON job and schedule it every 1 or 2 minute or even 5 minute. and in that PHP script check any auction which has expired and then send email to the winner..
e.g.
$sql = "select * from auctions where auctionEndTime < UNIX_TIMESTAMP()";
//execute query
foreach($rows as $row)
{
//send email and other tasks
}
精彩评论