e1seix Posted May 30, 2008 Share Posted May 30, 2008 Hi all, Have a bit of a question. Was wondering does anyone have any hints or links to code that would set up an SQL table where after a specified date the record would automatically delete itself. The reason why I ask is that I have an affiliate site (so shoot me! lol) and I can offer certain discount codes for limited times only and rather than have to keep on manually deleting the codes when they expire, at the time of inserting a table entry I could enter an expiry date, it would make life so much easier. What kind of table rows would I need etc and - can it be done full stop? Any tips? Cheers, Link to comment https://forums.phpfreaks.com/topic/108013-auto-delete-after-certain-date/ Share on other sites More sharing options...
rhodesa Posted May 30, 2008 Share Posted May 30, 2008 i'm not a big fan of deleting stuff. unless the table is going to get HUGE, which it sounds like it will not, just have a column for an expiration date, and in your php when you select the current codes, filter out the expired ones with a where clause. this way you will always have the old ones for reference/auditing/etc. if you feel you HAVE to delete them, still use the expiration, and create a php script that runs a DELETE FROM tablename WHERE expiration_date < NOW() then run the script with a cronjob every night ...but again...i wouldn't delete them, just filter Link to comment https://forums.phpfreaks.com/topic/108013-auto-delete-after-certain-date/#findComment-553614 Share on other sites More sharing options...
fenway Posted May 30, 2008 Share Posted May 30, 2008 version 5.1 has an event scheduler.... Link to comment https://forums.phpfreaks.com/topic/108013-auto-delete-after-certain-date/#findComment-553798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.