TecTao Posted March 4, 2008 Share Posted March 4, 2008 I am analyzing the tables of a DB created by another developer. One aspect I would like to use is a table that after a certain period of time table rows automatically delete. This is their token table. Among different things inserted is a time stamp that apparently sets a clock timer to remove the row after a period of time. The information is automatically removed like a time driven cookie. 1) What would a table like this be called so I can research creating one? 2) What is it about this type of table that makes it unique to remove rows? Thank you in advance. Mike Link to comment https://forums.phpfreaks.com/topic/94255-how-to-create-a-token-table-that-removes-rows-after-specific-time/ Share on other sites More sharing options...
aschk Posted March 4, 2008 Share Posted March 4, 2008 MySQL doesn't have a scheduler (unlike MS SQL) so you can't do this using the database. Your best option is to have a cron job run which checks the database table for records that have expired and deletes them. DELETE FROM <table name> WHERE `timestamp_column_name` < DATE_SUB(NOW(), INTERVAL 30 MINUTES) This statement will delete all entries that are older than 30 minutes. You might want to test it though, as i did it "off the cuff". Link to comment https://forums.phpfreaks.com/topic/94255-how-to-create-a-token-table-that-removes-rows-after-specific-time/#findComment-482901 Share on other sites More sharing options...
fenway Posted March 4, 2008 Share Posted March 4, 2008 5.1 does have an event schedule. Link to comment https://forums.phpfreaks.com/topic/94255-how-to-create-a-token-table-that-removes-rows-after-specific-time/#findComment-483269 Share on other sites More sharing options...
aschk Posted March 5, 2008 Share Posted March 5, 2008 Mmm, 5.1.6 to be precise. See http://dev.mysql.com/doc/refman/5.1/en/events.html for further information regarding events. note: going to have a play with 5.1.23 now Link to comment https://forums.phpfreaks.com/topic/94255-how-to-create-a-token-table-that-removes-rows-after-specific-time/#findComment-483742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.