|
|
|
|
![]() ![]() |
Apr 22 2007, 01:01 AM
Post
#1
|
|
|
Super Member Group: [HOSTED] Posts: 651 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
I need an operation that involves increasing the MySQL field value of all records by 1 every 15 or 30 minutes. Since hundreds or thousands of records are present, there must be an automatic script/program that can do this. Think in terms of game sites which increase your army/gold every update. Basically I'm doing the same thing.
How do I setup my database/table to do that? |
|
|
|
Apr 23 2007, 04:59 AM
Post
#2
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
You'd probably need to run a simple script as a cron job. That's the only possible way I know of. Correct me if I'm wrong - but MySQL doesn't have inbuilt time based triggers.
The SQL statement that has to be run looks like: CODE UPDATE table_name SET the_field_to_update = the_field_to_update + 1; This should update the required field for all of the records stored in the table in one go - producing exactly the effect you're looking for. However, the field needs to be numeric (INTEGER or DOUBLE) for this to work. |
|
|
|
May 5 2007, 06:37 PM
Post
#3
|
|
|
Super Member Group: [HOSTED] Posts: 651 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
In the Operations panel, I don't see an option to enter cron job scripts. Where do I put this in?
|
|
|
|
May 6 2007, 09:59 AM
Post
#4
|
|
|
the Q Group: [HOSTED] Posts: 1,017 Joined: 13-July 05 From: Lithuania, Vilnius Member No.: 7,059 |
If you're talking about PhpMyAdmin, of course not, to run cron jobs, you can use CPanel Cron Jobs, the unix style or standard, whatever you want, you'll need to have a file which does the operation you want and the right fields and tables to do it.
|
|
|
|
Nov 4 2007, 02:23 PM
Post
#5
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 28 Joined: 4-November 07 Member No.: 25,937 |
Use this command:
CODE mysql --user=username --host=host --password=password dbname < somefile.sql somefile.sql should contain your SQL commands seperated with a semicolon. I'm not sure if this'll work what it's worth a try. |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 30th August 2008 - 01:46 PM |