View previous topic :: View next topic |
Author |
Message |
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Sun Oct 12, 2008 17:55 Post subject: MySQL expiration |
|
|
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 |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Oct 13, 2008 0:45 Post subject: |
|
|
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 |
|
|
TroveLord
Joined: 22 Nov 2006 Posts: 136 Location: Italy
|
Posted: Mon Oct 13, 2008 9:12 Post subject: |
|
|
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 |
|
|
|