Forum Moderators: coopster

Message Too Old, No Replies

Deleting from database if idle

         

nshack31

1:35 pm on Mar 26, 2005 (gmt 0)

10+ Year Member



I have a league database and if a user leaves the league then the date that he left is entered into the database using...

$today=time();

the pseudo code for what I wish to do is this..


if DATE LEFT = 3 MONTHS AGO
{
DELETE USER FROM DATABASE
}

what is the code for "DATE LEFT = 3 MONTHS AGO "?

OR

rathar than use the IF statement could i simply add it to the DELETE query?

ie. DELETE USER FROM DB WHERE DATELEFT = 3 MONTHS AGO?
Can anybody help?

Thankyou

dcrombie

2:26 pm on Mar 26, 2005 (gmt 0)



In postgres the query is:

DELETE FROM users WHERE date_left<NOW() - INTERVAL '3 months'";

should be similar in MySQL ;)

nshack31

6:14 pm on Mar 26, 2005 (gmt 0)

10+ Year Member



$query="SELECT * FROM link WHERE present = 'No' AND dateleft < DATE_SUB(NOW(), INTERVAL 3 MONTH)";

This is the code i use for PHP but it returns all results, even if not 3 months old. I use $today=time(); to write the time that the user left (dateleft) into the DB

Can anybody help?!