By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,748 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,748 IT Pros & Developers. It's quick & easy.

Autodelete?

P: n/a
I have a database where I'm storing some user information, but I only want
the entries to remain in the database for a certain amount of time (say 72
hours). I have a datetime field in my database so I can manually tell, but
obviously that will be a real headache.

I thought maybe I could do some php in a private script to search through
the database and delete rows where time has expired, but not sure really how
that would work.

Also, I doubt it... but is there are way to set up mySQL entries to
autodelete after a certain time?

Hope you guys can help with some advice.
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Ganon wrote:
I have a database where I'm storing some user information, but I only want
the entries to remain in the database for a certain amount of time (say 72
hours). I have a datetime field in my database so I can manually tell, but
obviously that will be a real headache.

I thought maybe I could do some php in a private script to search through
the database and delete rows where time has expired, but not sure really how
that would work.

Also, I doubt it... but is there are way to set up mySQL entries to
autodelete after a certain time?

Hope you guys can help with some advice.


Assuming you're on Linux, you could set up a cron job to run a PHP (or
whatever) script that executes your query for you.

-Jay

Jul 17 '05 #2

P: n/a
cron?
"Jay Moore" <ad*****@isp.tld> wrote in message
news:ql***************@twister.rdc-kc.rr.com...
Ganon wrote:
I have a database where I'm storing some user information, but I only want the entries to remain in the database for a certain amount of time (say 72 hours). I have a datetime field in my database so I can manually tell, but obviously that will be a real headache.

I thought maybe I could do some php in a private script to search through the database and delete rows where time has expired, but not sure really how that would work.

Also, I doubt it... but is there are way to set up mySQL entries to
autodelete after a certain time?

Hope you guys can help with some advice.


Assuming you're on Linux, you could set up a cron job to run a PHP (or
whatever) script that executes your query for you.

-Jay

Jul 17 '05 #3

P: n/a
Jay Moore wrote:
Ganon wrote:
I have a database where I'm storing some user information, but I only
want
the entries to remain in the database for a certain amount of time
(say 72
hours). I have a datetime field in my database so I can manually tell,
but
obviously that will be a real headache.

I thought maybe I could do some php in a private script to search through
the database and delete rows where time has expired, but not sure
really how
that would work.

Also, I doubt it... but is there are way to set up mySQL entries to
autodelete after a certain time?

Hope you guys can help with some advice.


Assuming you're on Linux, you could set up a cron job to run a PHP (or
whatever) script that executes your query for you.


Or you could set up a webbug to run when the site is hit...

For instance you could put something like at the bottom of all your pages:
<script type="text/javascript" src="cleaner.php"></script>

Doing this allows you to do your database maintenance whenever your
website gets a visitor. If you want to allow things like Googlebot to do
it too, then you could use an IMG tag:
<img src="cleaner.php" width="1" height="1" alt="">

If you go the script way, you could add "document.write("");" at the end
of the document so that browsers will get a javascript file when they
include it.

Just my $.02

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
SEO Competition League: http://seo.koivi.com/
Jul 17 '05 #4

P: n/a
Ganon wrote:
cron?
"Jay Moore" <ad*****@isp.tld> wrote in message
news:ql***************@twister.rdc-kc.rr.com...
Ganon wrote:

I have a database where I'm storing some user information, but I only
want
the entries to remain in the database for a certain amount of time (say
72
hours). I have a datetime field in my database so I can manually tell,
but
obviously that will be a real headache.

I thought maybe I could do some php in a private script to search
through
the database and delete rows where time has expired, but not sure really
how
that would work.

Also, I doubt it... but is there are way to set up mySQL entries to
autodelete after a certain time?

Hope you guys can help with some advice.


Assuming you're on Linux, you could set up a cron job to run a PHP (or
whatever) script that executes your query for you.

-Jay



1.) If you wouldn't mind, please don't top-post. It makes reading a
bitch. ;)

2.) Cron jobs are akin to the Task Scheduler on Windows. You set it up
to run every X minutes/hours/days/etc... and it will do whatever you
tell it to (ie - run a script, backup a database, recursively remove all
files starting from /). If you have a GUI installed, they're very easy
to set up. If not, Google 'cron job' and follow the instructions.

-Jay

Jul 17 '05 #5

P: n/a
Uzytkownik "Ganon" <ev***********@hotmail.com> napisal w wiadomosci
news:Ze*******************@news-binary.blueyonder.co.uk...
I have a database where I'm storing some user information, but I only want
the entries to remain in the database for a certain amount of time (say 72
hours). I have a datetime field in my database so I can manually tell, but
obviously that will be a real headache.

I thought maybe I could do some php in a private script to search through
the database and delete rows where time has expired, but not sure really how that would work.

Also, I doubt it... but is there are way to set up mySQL entries to
autodelete after a certain time?


Just delete the expired rows before you do an insert, and in your select
statements, omit the expired ones. Achieve the same goal with fewer
headaches.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.