mcal_expunge ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dark[NSF]
Forum Newbie
Posts: 18
Joined: Thu Oct 06, 2005 9:25 am
Location: Palm Bay, FL
Contact:

mcal_expunge ??

Post by Dark[NSF] »

Hello, I'm new here. Looks like a great community 8O


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. :wink:
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post 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.
Dark[NSF]
Forum Newbie
Posts: 18
Joined: Thu Oct 06, 2005 9:25 am
Location: Palm Bay, FL
Contact:

Post 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
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
Dark[NSF]
Forum Newbie
Posts: 18
Joined: Thu Oct 06, 2005 9:25 am
Location: Palm Bay, FL
Contact:

Post by Dark[NSF] »

how does one setup a cron job? is there a tutorial or a section in the SQL readme?

cheers.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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
Post Reply