Baseball Posted December 24, 2009 Share Posted December 24, 2009 If i use DELETE FROM WHERE Id running_time > XXX Does it run each time page is loaded? or only when it finds the WHERE ID = RUNNING_TIME > XX ? Link to comment https://forums.phpfreaks.com/topic/186240-delete-from/ Share on other sites More sharing options...
pneudralics Posted December 24, 2009 Share Posted December 24, 2009 Yes each time the page is loaded, the codes are reloaded. Link to comment https://forums.phpfreaks.com/topic/186240-delete-from/#findComment-983552 Share on other sites More sharing options...
Baseball Posted December 24, 2009 Author Share Posted December 24, 2009 Yes each time the page is loaded, the codes are reloaded. How do i set up to only load if user hasn't refreshed in 5minutes? cause i dont want to run it each refresh.. lol Link to comment https://forums.phpfreaks.com/topic/186240-delete-from/#findComment-983553 Share on other sites More sharing options...
Buddski Posted December 24, 2009 Share Posted December 24, 2009 You would need to store the last time (time()) the query was executed in the database.. Then before running the query do something like this.. $sql = "SELECT last_refresh_time FROM refresh_table WHERE id=ID LIMIT 1"; $sql_query = mysql_query($sql); $l = mysql_fetch_assoc($sql_query); if (time() - $l['last_refresh_time'] > 300) { // run the delete query // mysql_query("DELETE FROM WHERE Id running_time > XXX"); // then update the time mysql_query("UPDATE refresh_table SET last_refresh_time = '".time()."' WHERE id=ID"); } Link to comment https://forums.phpfreaks.com/topic/186240-delete-from/#findComment-983573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.