开发者

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'");
开发者_C百科

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.


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜