Jump to content

need to slow down the rotation interval of a date query


terrypeck36

Recommended Posts

$query = "SELECT * FROM items WHERE releasedate <= gettoday() ORDER BY releasedate DESC LIMIT 0, 3";


i have a page that list my 3 newest items, i release one new item a day. i would like to slow down the rotation so the 3 newest items are displayed for 1 week before the query executes again and displays the 3 newest items for another week, so items being released in the middle of the week will never be displayed. 

for example, on monday i would like the query to  select the new releases from sat, sun and fri and display those 3 items all week until next monday when the query executes again and displays the 3 new items for another week

i have played around with interval but cannot get anything to work.  releasedate is a hardcoded int type

can this be done? any help would be greatly appreciated
I had a problem along this line a week or so back.

I had to pipe data out from a ssh command into 5 different boxes, and quite understandably I didn't want this command to be run everytime the user hit the page.

So I took the results and inserted them into what id call a cache table in the database with a timestamp, and when the user hits the page it checks the timestamps of any data, if any and if it is within the expiry time then simply use the data from there, otherwise flush the old stuff out, if any and again generate the data from the other servers.

Not sure if i explained it very well, but using this method has put one of our longest loading pages on par with the rest of them, and the best thing is that it doesnt require a cron script, as it only gathers data on demand and the cache table is self maintaining.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.