Old-Hades
Old-Hades

Reputation: 11

cron file to update the database sequentially after every run

im redesigning a mmorpg game and im in a bit of a pickle on this one. i have the following code on the daily cron file.

dbn("update mygame set event = '11' where event = '10'");

now...

this file runs once a day. i would like to update the database in a way such day 1 ----- event =10, day 2 ----- event =11, day 3 ----- event =12 ...etc, in other words, once the event is set it will automatically update itself till it dies out. Hence day 1

dbn("update mygame set event = '10' where event = '9'");

day 2

dbn("update mygame set event = '11' where event = '10'");

so on and so forth.

Any ideas? Thank you in advance for reading.

Upvotes: 1

Views: 454

Answers (2)

Dan Grossman
Dan Grossman

Reputation: 52372

1) Make your event column a numeric type like an int, not a string containing a number

2) dbn("UPDATE mygame SET event = event + 1")

However, you probably don't need this column at all. If all it does is count days, then store the start date and COMPUTE the number of days elapsed wherever you're using that value. You won't have to run any query each day.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798746

UPDATE mygame
  SET event=event+1
  WHERE <useful condition>

Upvotes: 0

Related Questions