Welcome Guest, Not a member yet? Register   Sign In
Developing an auction application / scheduled status change
#1

[eluser]Unknown[/eluser]
Hello,

I am developing an auction application, e.g. like ebay.

Now I've the following problem:

If an auction for a given product ends, the status of the auction has to be changed to expired. As far as I know there in no possibility to run a scheduled task with php (eg. run task on 26th of March 2010 at 12:04:01 pm).

The only way it works (that I know) is to create a cron. There are two solutions I'm thinking about.

First one:

With every auction I create a new cron, which runs once. Therefore I start a script, which would be like "www.domain.tld/auction/check_expired/auction_id" where "auction" a controller represents and "check_expired" a function and the "auction_id" the parameter (surprise surprise) id of the auction.

The second one:

I've just one cron job, which runs every minute and checks all auctions, whether they are expired or not. The benefit is, that I've just one cron that runs more often.


For me the first option sounds better, since I've not so much experience with the effects of crons on the performance I don't know, if the second option wouldn't be better.

Does somebody has experience with such problems, or maybe even knows a third option, how to solve the problem.

I am thankful for every advice!
#2

[eluser]bema2004sw[/eluser]
I have a similar site made in CI and I used this approach:

When a user post an ad, insert in db time of posted and time when ad expires.

$this->db->set('time_posted', time());
$this->db->set('time_expire', time()+60*60*24*30); // Mine is 30 days.



Hope this helps.
Regards.
#3

[eluser]woony[/eluser]
Personally I wouldn't do it with a cron job.
Why? Because the data in your database doesn't really matters if noone is checking your site right?
So, just put some sort of check when you fill your page. Lik berna above, keep your expired time in your db, and in your select just check with current date and when it is passed, have your "expired" functions instead of your normal ones. So if noone visits your site say from 12 to 6, you are not doing unnecessary cron jobs.

Just how I would do it Smile




Theme © iAndrew 2016 - Forum software by © MyBB