Re: Garbage Collection

From: Date: Sat, 03 Feb 2001 10:32:46 +0000
Subject: Re: Garbage Collection
Groups: php.db 
Request: Send a blank email to php-db+get-6339@lists.php.net to get a copy of this message
Addressed to: Nashirak Bosk <nashirak@mindspring.com> php-db@lists.php.net ** Reply to note from Nashirak Bosk <nashirak@mindspring.com> Sat, 03 Feb 2001 04:05:07 -0500 > > I am writing a PHP script that accesses a MYSQL database when the > adminstrator (the client) wants to add something to a calendar > (dynamically PHP generated). I have written the callendar and have > the whole thing setup to be able to update it regularly, through a > easy user interface on the adminstration page. The problem that I am > forseeing though is that, the person I am doing this for is going to > keep adding information to the calendar thereby adding more rows to > the database, and never deleting any of it. Since this is a calendar, > I thought I might right some sort of "Garbage Collector" deletes old > information on the first of the month. The way I would have to do > this though, is it to go through all the fields, parse the Date > field, and check to see if the date is less than the current. My > question is, is there a faster way to do this. Mabye some MYSQL built > in function that I am missing or something. Any help would be > appreciated. Throw this in to the update program somewhere: mysql_query( "DELETE " . "FROM table " . "WHERE somedate < SUBDATE( NOW(), INTERVAL 30 DAY ) " ); Everything older than 30 days will be deleted. Rick Widmer Internet Marketing Specialists http://www.developersdesk.com

« previous php.db (#6339) next »