0

I have a DBMS assignment to create an entire online bidding website that allows users to do many things like bidding on a timed auction, buy-it-now based on timed availability, and search among MANY more things. I've completed the website, with one minor exception: once a user wins a timed auction, that user must be notified that s/he is the winner and given 24hrs to checkout the item.

My early approaches consisted of simple PHP scripts that queried the DB when the user was on the page to see if the bid time ended and to see who the winner is, but there are two things wrong with that approach. 1. The user has to constantly refresh to find out if s/he won -- if they're on the page shopping. 2. If the user doesn't log into the site for a month after the auction ended, s/he will not know for a month that s/he won the auction and therefore misses the 24 hr window to checkout.

I've been reading about cron jobs, but my concern is that, since they are scheduled jobs, there are no convenient times to schedule the jobs so that they get processed efficiently. What I mean is that I can't continuously monitor and let every user who wins know instantly after the auction ends.

I also read on PHP exec( ), but I'm not sure that it's the tool that I need to run this task because once exec( ) finishes, it doesn't re-run.

So I guess, my question is if anyone has an idea of what I could implement to help me with this task.

4

2 回答 2

1

您应该使用 cron - 让它每分钟左右运行一次以检查数据库以查看某些拍卖是否结束。我认为您正在解释的更大问题是对用户的通知。如果是这种情况,他们可能不在网站上(或在他们获胜时出现在某个随机页面上),那么不要依赖通过网站通知他们,当然也不要依赖他们可能会或可能不会向网站发出的 PHP 请求。相反,考虑让 cron 调用 PHP 来检查获胜者,向他们发送电子邮件以通知他们。

想想 Facebook(只是因为它的用户群是最普遍的体验示例)——如果你在网站上,他们会提供一个通知区域,但如果你有一段时间不上,他们会向你发送一封电子邮件,让你知道发生了什么事。这是你应该做的。

于 2012-12-02T00:49:02.980 回答
0

您应该重新考虑使用 cron 调度,您可以以非常快的间隔运行作业。

于 2012-12-02T00:46:04.317 回答