gentle Posted January 5, 2010 Share Posted January 5, 2010 MySQL serverversion: 5.0.32-Debian_7etch11-log I'm bit of a newbie at MySQL and PHP which I'm attempting to use. I'm really looking forward to (with help from friends and forumusers) created my very first script and I'm not giving up. However, here comes my problem: I have a table with rows, every row has a unique ID (int 11) which is rising for every new row. 1 and up. I want a row to be able to expire in a certain amount of time. Let's say 3600 secound (1 hr). First it's created by a PHP script. 1 hour later I want it to either delete itself or change value in a column named "expired" from 1 to 0. Anyone got a solution to this? I'm empty. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/187193-row-to-expire/ Share on other sites More sharing options...
Zane Posted January 5, 2010 Share Posted January 5, 2010 I'm no MySQL expert but I don't believe there is a way to run SQL queries on intervals WITHOUT a CGI/PHP/Perl/etc script running them. As far as I know, a MySQL server it meant just for what it is.. to be a database... with the complementary code to manipulate its data. You should look into setting crontabs http://en.wikipedia.org/wiki/Cron From which point you can write a PHP script to do what happens upon expiration. All this script would do is query the database for records whose timefield is expired.. according to how you have it formatted.... and delete it, mark it expired, whatever Quote Link to comment https://forums.phpfreaks.com/topic/187193-row-to-expire/#findComment-988592 Share on other sites More sharing options...
fenway Posted January 6, 2010 Share Posted January 6, 2010 Though 5.1 does have an event scheduler. Quote Link to comment https://forums.phpfreaks.com/topic/187193-row-to-expire/#findComment-989552 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.