Re: Periodically delete old records from mysql table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Re: cron jobs... this is my recommended solution. They don't need to be set up on the same server as your website. They can be on any host, and can just use curl to call a particular url on your site at set intervals.

~Ted



On 27-May-08, at 9:06 AM, Richard Heyes wrote:

> tedd wrote:
At 1:26 PM +0200 5/27/08, Stefano Esposito wrote:
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 :)

Depending on how busy your website is, you might not need to alter you schema at all. ie Add a query to one page of your website that only runs when it's minute 1 of any (or a particular) hour. Depending on how busy your website is it may mean that the query runs too much or too little.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux