logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
MySQL expiration

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Sun Oct 12, 2008 17:55    Post subject: MySQL expiration Reply with quote

Im begineer with MySQL and so I realy on you.

Is in mysql something like event?

I want to run script when iExpiration expires. (row expire<=NOW() I think)

Another way would be unnecessary complicated...
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Mon Oct 13, 2008 0:45    Post subject: Reply with quote

No, you access MySQL from scripts, so you would need to check whether the entry has expired from another event. You could use a mod heartbeat for this, so long as you didn't write it in too clunky a fashion.

Funky
Back to top
View user's profile Send private message
TroveLord



Joined: 22 Nov 2006
Posts: 136
Location: Italy

PostPosted: Mon Oct 13, 2008 9:12    Post subject: Reply with quote

I use TIMESTAMPDIFF for the purpose.

Code:
int GetTimeStampDiff(string sTimestamp, string sUnit = "second")
{   
   int n;   
    SQLExecDirect("SELECT TIMESTAMPDIFF("+sUnit+", '"+sTimestamp+"', NOW())");
   if(SQLFetch() == SQL_SUCCESS)
      n = StringToInt(SQLGetData(1));
   return n;
}

This will return the seconds (or whatever unit of measurement of time you prefer) between given timestamp and the current one. It returns real life values.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group