Page 1 of 1
mcal_expunge ??
Posted: Thu Oct 06, 2005 9:37 am
by Dark[NSF]
Hello, I'm new here. Looks like a great community
Anyway, on to my question. I'm creating a PHP/SQL based classified ads page and I'd like each ad to have a shelf life of a certain amount of weeks; after which they would just be purged.
Is there a good way to do this? is this all controlled via mysql?
thanks in advance.

Posted: Thu Oct 06, 2005 9:48 am
by pilau
You use a MySQL DB to store the dates those ads were created.
When loading the ads on your website (or use a cron job) you check whether their date has expired and then you can either do:
A) Delete the ads from the DB (or wherever you stored them). This option could have a big impact on performance if you'll use it when loading them on your website. It's better for cron jobs.
B) Choose to not view them (skip these ads and move on to the next). This option is better if you're going to perform it when loading the website, and useless if you're going to use cron jobs.
Posted: Thu Oct 06, 2005 10:06 am
by Dark[NSF]
pilau wrote:You use a MySQL DB to store the dates those ads were created.
When loading the ads on your website (or use a cron job) you check whether their date has expired and then you can either do:
A) Delete the ads from the DB (or wherever you stored them). This option could have a big impact on performance if you'll use it when loading them on your website. It's better for cron jobs.
B) Choose to not view them (skip these ads and move on to the next). This option is better if you're going to perform it when loading the website, and useless if you're going to use cron jobs.
I like the idea of not displaying them if they are past a certain date, and the admin would just go in and clean up if they wanted to; but, can you give me more info on "cron jobs"?
thanks
Posted: Thu Oct 06, 2005 10:26 am
by Roja
Do a select by date (older than todays date + 7 days), and then there is no performance hit per page load (for the most part).
Also have a cron that removes entries older than 7 days at midnight each day (during a non-peak access time).
That way, each page load is snappy, and there is never more than 1 day of extra ads that the select by date avoids.
Posted: Thu Oct 06, 2005 4:18 pm
by Dark[NSF]
how does one setup a cron job? is there a tutorial or a section in the SQL readme?
cheers.
Posted: Thu Oct 06, 2005 4:24 pm
by Roja
Dark[NSF] wrote:how does one setup a cron job? is there a tutorial or a section in the SQL readme?
cheers.
viewtopic.php?t=2737&highlight=setup+cron