Desaster Posted November 17, 2013 Share Posted November 17, 2013 hello, I have a table in SQLite database how to clear it every weak ? Link to comment
xXMADEXx Posted November 17, 2013 Share Posted November 17, 2013 (edited) You can just check the date..something like this, although this code hasn't been tested local nextClearDate = { } function checkDate ( ) local t = getRealTime ( ) local day = t['monthday'] local month = t['month']+1 local year = t['year'] + 1900 if ( #nextClearDate <= 0 ) then nextClearDate = { day = day, month = month, year = year } end if ( nextClearDate.year < year )then executeClear ( ) end if ( nextClearDate.month < month ) then executeClear ( ) end if ( nextClearDate.day < day and nextClearDate.month <= month ) then executeClear ( ) end end setTimer ( checkDate, 600000, 0 ) function executeClear ( ) dbQuery ( databaseconnection, "DELETE FROM TableName" ) local t = getRealTime ( ) local day = t['monthday'] local month = t['month']+1 local year = t['year'] + 1900 nextClearDate.day = nextClearDate.day + 7 if ( nextClearDate.day > 30 ) then nextClearDate.day = 1 nextClearDate.month = nextClearDate.month + 1 end if ( nextClearDate.month > 12 ) then nextClearDate.year = nextClearDate.year + 1 nextClearDate.month = 1 end end Edited November 17, 2013 by Guest Link to comment
Renkon Posted November 17, 2013 Share Posted November 17, 2013 it's not DELETE * FROM table its DELETE FROM table Link to comment
Desaster Posted November 17, 2013 Author Share Posted November 17, 2013 renkon what you sayed is to delte a part of the table I need to delte the whole table Content thnx xXMADEXx Link to comment
Renkon Posted November 17, 2013 Share Posted November 17, 2013 Using DELETE FROM table removes all Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now