Dablue Posted June 15, 2007 Share Posted June 15, 2007 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 More sharing options...
Dablue Posted June 15, 2007 Author Share Posted June 15, 2007 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) Link to comment https://forums.phpfreaks.com/topic/55755-cron-delete-based-on-date/#findComment-275487 Share on other sites More sharing options...
bubblegum.anarchy Posted June 15, 2007 Share Posted June 15, 2007 Sessions can also store the shopping progress and when complete be placed into the database as a more permanent record. Link to comment https://forums.phpfreaks.com/topic/55755-cron-delete-based-on-date/#findComment-275598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.