Re: Deleting mySql records based on dates

From: Date: Wed, 21 Feb 2001 13:19:54 +0000
Subject: Re: Deleting mySql records based on dates
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-40945@lists.php.net to get a copy of this message
The reason I used that route was to show the logic. Yes its long- some people may not want a mysql reliant way of doing it. Kevin ----- Original Message ----- From: "Christian Reiniger" <creinig@mayn.de> To: <php-general@lists.php.net> Sent: Wednesday, February 21, 2001 1:11 PM Subject: Re: [PHP] Deleting mySql records based on dates > On Wednesday 21 February 2001 14:00, Kevin Cawthorne wrote: > > > Try something like: > > > > $time = time(); // unix time now > > $day_limit = 28; // how many days to allow > > > > $day = 86400; // how many seconds in 24 hours(1 day) > > $difference = bcmul($day_limit,$day); // multiply the seconds($day) by > > the day limit($day_limit) > > $limit = bcsub($time,$difference); > > > > $sql = mysql_query("delete from table where > > date<='".$limit."'", $dbh); > > Eeeek. Have a look at the Mysql manual sometime soon! > > $sql = mysql_query("delete from table where datefield <= DATE_SUB(NOW(), > INTERVAL $days DAY)", $dbh); > > -- > Christian Reiniger > LGDC Webmaster (http://sunsite.dk/lgdc/) > > "These are the people who proudly call themselves "hackers" -- > not as the term is now abused by journalists to mean a computer > criminal, but in its true and original sense of an enthusiast, > an artist, a tinkerer, a problem solver, an expert." > > - ESR > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#40945) next »