bschultz Posted March 24, 2007 Share Posted March 24, 2007 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 Quote Link to comment Share on other sites More sharing options...
bschultz Posted March 24, 2007 Author Share Posted March 24, 2007 I should add that some records in the DB might be in the future, so I have to be sure to only delete records in the past, not today or in the future. Quote Link to comment Share on other sites More sharing options...
artacus Posted March 25, 2007 Share Posted March 25, 2007 DELETE FROM myTab WHERE dtFld < CURDATE() Quote Link to comment Share on other sites More sharing options...
bschultz Posted March 25, 2007 Author Share Posted March 25, 2007 Simple case of me thinking WAY too much! Thanks. 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.