AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL Question (https://forums.alliedmods.net/showthread.php?t=12607)

BigWalnutZ 04-19-2005 10:31

SQL Question
 
I need a query that will delete any rows in the database that are more than 2 weeks old. It would be nice if this were able to be easily changed just by putting a 2 or 3 or 4 weeks etc, instead of having some crazy timestamp contraption.

Any help is appreciated. Mine was supposed to be 2 weeks and it was deleting way before that.

BigWalnutZ 04-19-2005 17:39

BUMP

slurpycof 04-19-2005 20:23

look at the code for my frequent fragger program.
http://forums.alliedmods.net/showthread.php?t=12149

Here is the db maintenance part of it

Code:
 public schedule_dbmaintenance()  //Clean up database  {     new thetimeis[16],dbdecay_time[16]     get_time("%H:%M",thetimeis,16)     get_cvar_string("amx_ffpdbmaintenance",dbdecay_time,16)     if(equal(thetimeis,dbdecay_time)){         new history = get_cvar_num("amx_ffphistory")         //Delete player from database after certain number of days not on server         result = dbi_query(dbc,"DELETE FROM  freqfragger WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date ) >=%d",history )         result = dbi_query(dbc,"DELETE FROM  freqfragger WHERE steamid = 'STEAM_ID_PENDING'")         new slotdecay = get_cvar_num("amx_ffpdecay")         new decaypct = (100 - slotdecay)         //Remove percentage of players total time if not on server in the last day         result = dbi_query(dbc,"UPDATE freqfragger SET steamid=steamid, connecttime=connecttime*.%i, date=date WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date ) >=1 ",decaypct)         dbi_free_result(result)     }     return PLUGIN_CONTINUE  }

BigWalnutZ 04-20-2005 09:57

@slurpycof:
Thanks a ton!!! I will be sure to credit your work.


All times are GMT -4. The time now is 09:57.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.