Raised This Month: $ Target: $400
 0% 

SQL Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BigWalnutZ
Junior Member
Join Date: Apr 2005
Old 04-19-2005 , 10:31   SQL Question
Reply With Quote #1

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.
__________________
I am 77% addicted to Counterstrike. What about you?
BigWalnutZ is offline
BigWalnutZ
Junior Member
Join Date: Apr 2005
Old 04-19-2005 , 17:39  
Reply With Quote #2

BUMP
__________________
I am 77% addicted to Counterstrike. What about you?
BigWalnutZ is offline
slurpycof
Senior Member
Join Date: Nov 2004
Old 04-19-2005 , 20:23  
Reply With Quote #3

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  }
slurpycof is offline
BigWalnutZ
Junior Member
Join Date: Apr 2005
Old 04-20-2005 , 09:57  
Reply With Quote #4

@slurpycof:
Thanks a ton!!! I will be sure to credit your work.
__________________
I am 77% addicted to Counterstrike. What about you?
BigWalnutZ is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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