Jump to content

[SOLVED] Automatically delete all records prior to today


bschultz

Recommended Posts

Hi everyone, and thanks in advance for the help.

 

I would like to have a way to remove all records in a database where the "date" column is prior to today (something like CURDATE() - INTERVAL 1 day)

 

But, here's my problem.  I know that MySQL 5 has an "event" feature that will do this for me, but I want it run by a script.  I also don't want it run via cron.  I want an absolute php and mysql newbie to be able to get this working.

 

I was thinking of adding a few lines on a regular web page that would delete the rows in the background when the public visits that page (could be the index page, could be another page)...but what if that page doesn't get visited each day?  Plus, that seems to be overkill, and not entirely safe.

 

I could add the delete feature to the existing "write it to the db" script, so that every time something is written to the DB, it will purge the old records.  But this script doesn't get run very often in the summer.  How would I delete all the old records, regardless of how long ago they were entered?

 

Is there another way to go about this that I'm not thinking of?  Any other suggestions?

 

Thanks for your time!

 

Brian

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.