Jump to content

Recommended Posts

Hi Folks,

 

I've made a shopping cart and basically I want to delete data out of a few tables which isn't needed (and I want to know the sql on how to do it!)

 

Basically they'll be loads of order rows (amongst other things) which will be stored and won't be needed (the customer hasn't completed the order etc). I'm thinking the best way to clear out the data which isn't needed is via cron.

 

I'm going to log when each row is added to the table with a timestamp... I then want to be able to delete rows from several tables which are 10 days old... I've got a cookie logged on the customer's pc which expires after a week. This cookie is their unique id which logs loads of of different things in various tables (order rows, coupons, postage etc.)

 

I want to put the sql into a cron job and run it everyday.

 

Anyone any ideas... I've tried messing with ADDDATE but I'm still not sure what I'm doing.

 

Thanks in advance,

Link to comment
https://forums.phpfreaks.com/topic/55755-cron-delete-based-on-date/
Share on other sites

Would it be a 2 step process... ?

 

1. Get the timestamp from the table.

2. Then add 10 days to the timestamp and compare it against today?

 

Or

 

Can it be done in one sql statement? Something like?

 

DELETE FROM table WHERE CURDATE() > ADDDATE('date_logged', INTERVAL 10 DAY)

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.