Re: Periodically delete old records from mysql table
| From: | Robin Vickery | Date: | Tue, 27 May 2008 14:45:05 +0000 |
| Subject: | Re: Periodically delete old records from mysql table | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-274727@lists.php.net to get a copy of this message | ||
2008/5/27 Stefano Esposito <ragnarok@email.it>:
> Hi all,
>
> i'm wandering if there's some intelligent way to delete old records
> from a mysql table without using cronjobs (i can't), using PHP.
> This table has a field which stores the value returned from time(), and
> i want to do
>
> mysql_query("DELETE FROM
table WHERE
> time<='".(time()-86400)."'");
>
> at periodical intervals (say every 15 hours). Thanks for any hint :)
What version of MySQL? If it's >= 5.1.6, you can use the mysql event scheduler.
http://dev.mysql.com/tech-resources/articles/event-feature.html
http://dev.mysql.com/doc/refman/5.1/en/events.html
-robin