Skip to main content
Inspiring
March 22, 2010
Answered

auto archiving

  • March 22, 2010
  • 1 reply
  • 333 views

How would auto archiving a record work?

I was asked about archiving events automatically, as he wants less interaction with the website as possible.

I thought about it, the only way it could do it is if I check by date and if the current date is past the event date then put in archives.

But I do not think that is the best use of resources.

I do not understand cron either.

Is there any scripts out there or is the a good enough guide to help me understand it better

This topic has been closed for replies.
Correct answer David_Powers

You don't need to do anything to archive records unless your database is getting really big (millions of records).

Add a TIMESTAMP column to the table. This automatically adds the current date and time when a record is first inserted or updated. Then use your SQL query to retrieve items that were inserted or updated within a specified time span.

SELECT * FROM table

WHERE updated >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)

That would pick up items from the past month.

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
March 29, 2010

You don't need to do anything to archive records unless your database is getting really big (millions of records).

Add a TIMESTAMP column to the table. This automatically adds the current date and time when a record is first inserted or updated. Then use your SQL query to retrieve items that were inserted or updated within a specified time span.

SELECT * FROM table

WHERE updated >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)

That would pick up items from the past month.