Jump to content

Row to expire


gentle

Recommended Posts

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.  :wtf:  :confused:

 

Thanks!! :)

Link to comment
https://forums.phpfreaks.com/topic/187193-row-to-expire/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/187193-row-to-expire/#findComment-988592
Share on other sites

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.