Jump to content

Auto Delete After Certain Date


e1seix

Recommended Posts

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,  ;D

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.