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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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