Dmitri --

...and then Dimitri Marshall said...
% 
% Hey,
% Here's my situation. I'm making a message board and I want posts to be
% deleted after 30 days.

OK.


% 
% Does anyone know of a script, or how, I can delete an entry on my database
% after a certain amount of time (ie. 30 days) automatically.

1) This should probably be handled through cron so that a) it gets done
regularly and b) it doesn't get overdone.  Once you figure out how to
use 2) or 3) or something else, put the command(s) in a script and call
it once a day.

2) If, like Rolf, we assume that you have an epoch timestamp on each
entry, then just subtract 2592000 seconds from your current timestamp and
delete anything older (smaller) than that.

3) If you use date or datetime columns for your entries, then you can let
mysql do the math for you with something like

  delete from table where date < date_sub(now(),interval 30 days) ;

or so (untested).

For more info, check the mysql manual.


% 
% Dimitri Marshall


HTH & HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to