changing information in a field based on days past a date
Posted: Tue Jul 03, 2007 2:01 pm
I'm having difficulty even figuring out the proper language to search for this, so I apologize if there's a thread already on this topic.
What I'd like to do is change the value of a field based on the current date being an arbitrary number of days past a date stored in the row. For sake of argument, we'll say it's 30 days. This would be for an effective Time To Live for the row, when 30 days hits, the "active" field would be switched from "on" to "off".
Unfortunately, this is for MySQL 4.x, so triggers, my first thought, are totally thrown out. I don't have access to the server (beyond phpmyadmin) so no cron jobs. My only other thought is to have a piece of code that does a "set active = 0 where..." placed somewhere arbitrary that I expect users to hit on a daily basis (I'm thinking that it would do this any time the user lists all of the applicable rows).
Is there a better/easier/cleaner way to do this? It seems like an awful lot of excess queries to the server when this bit of code really only needs to fire once a day to be effective.
Thoughts/Comments/Ideas?
What I'd like to do is change the value of a field based on the current date being an arbitrary number of days past a date stored in the row. For sake of argument, we'll say it's 30 days. This would be for an effective Time To Live for the row, when 30 days hits, the "active" field would be switched from "on" to "off".
Unfortunately, this is for MySQL 4.x, so triggers, my first thought, are totally thrown out. I don't have access to the server (beyond phpmyadmin) so no cron jobs. My only other thought is to have a piece of code that does a "set active = 0 where..." placed somewhere arbitrary that I expect users to hit on a daily basis (I'm thinking that it would do this any time the user lists all of the applicable rows).
Is there a better/easier/cleaner way to do this? It seems like an awful lot of excess queries to the server when this bit of code really only needs to fire once a day to be effective.
Thoughts/Comments/Ideas?