adding a timer until the database info changes

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

adding a timer until the database info changes

Post by mickd »

hi, i was wondering how you could say for example someone presses a button, then a timer starts which for example 2 hours later changes the database information. like say field1 in table1 has a value of 10. someone submits a form in which 2 hours later would change field1 to 20 from 10.

any help appriciated greatly.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

MySQL doesn't have these capabilities, you'll have to use Cron or something similar to simulate what you are requesting.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Ambush Commander wrote:you'll have to use Cron or something similar to simulate what you are requesting.
exactly, just write out a crontab file to execute whatever you want on whatever interval you specify.

try a google for "crontab file examples" and I'm sure you'll find plenty.
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

hi, sorry for the slow reply, after looking at some site on google about it, i have a few questions.

on the sites it says crons are written in the format:
minute hour day month year(some say day of week here) command

1. can we write php/mysql codes where it says command? if so do we write the whole code there including the <?php ?> tags?
2. if you dont do it like that, do you just write the code into a .php file and where it says command specify where the file is?
3. sorry if these are noob questions but i was wondering what file extension cron files get saved as? is it just .cron?

thanks for any help, greatly appriciated.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you can NOT just write php code in the crontab file. YOu have to execute a php file from there (probably best to use the CLI).
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

k, thanks for the reply. grealy apprciated.
Post Reply