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 :)
Ciao,
Stefano
Stefano:
I can't help your wandering around, but if you are wondering about
how to periodically delete records from a dB without using a cron,
then this will work.
Create and set a field for "last_deletion" to current time.
When users accesses the dB, then have the process check current time
with "last_deletion" and if the "last_deletion" is greater than
current time plus 15 hours, then run the "delete old records" routine
and reset the "last_deletion" to current time.
That way, users accessing the dB will trigger the "delete old records" process.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php