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, Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted May 30, 2008 Share Posted May 30, 2008 version 5.1 has an event scheduler.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.