Page 1 of 1

Cron jobs or PHP Scheduler

Posted: Wed Aug 12, 2009 1:31 pm
by kaushikisalive1
Hi,

I am using MYSQL as my database and PHP as my programming language.I wanted to run a cron job which would run until the current system date matches the "deadline(date)" column in my database table called "PROJECT".Once the dates are same an update query has to run which would change the status(field of project table) from "open" to "close".

I am not really sure if cron jobs are the best way or I could use triggers or may be something else.Also I am using Apache as my web server and my OS is windows vista.


Also which is the best way to do it? PHP scheduler or cron jobs or any other method? can anybody enlighten me?

Re: Cron jobs or PHP Scheduler

Posted: Wed Aug 12, 2009 2:28 pm
by califdon
I have seen almost no instances where a database should be updated automatically, based on date or time. Probably there are some exceptions, but in nearly every case I've seen people describe, they are thinking that it's important that some status be maintained in the database on a realtime basis. That's the wrong way to think about a database. The data has absolutely no value until somebody uses it. So the proper way to do it, usually, is to store the criteria in the database, then process it when the data is accessed. What I'm saying is that it isn't at all important what the status flag value is while nobody is using the data. What is important is that users can determine the status at the time somebody accesses the data. You have a "deadline" field in each record, all you have to do is compare that with the current date, to determine the status. You don't need a status field. Indeed, it is a dependent field and, by data normalization rules, shouldn't be in your table at all.