473,412 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Autodelete?

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
5 2172
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: AlexM | last post by:
Hello All, Is there any way to pull the date via SNTP from a timeserver with ASP / VBscript? Thank you, Alex
1
by: Amol | last post by:
Hi, I want to fetch some values from a XML file, using a java program. I want to retrieve value of path tag for e.g<path>some path</path> tag.(Marked with **** in the below XML file Example) ...
2
by: Allan Bruce | last post by:
I have made a struct which has several fields and I initialise like this: MyStruct foo = {a, b, c, d, e}; I just added another field to the struct at the end, and I thought I would have to add...
30
by: John Carroll | last post by:
Does anyone have a function or procedure for converting integers to character strings? Thank you, John
0
KevinADC
by: KevinADC | last post by:
This is not a "Howto" article but a complete script. I wrote this script a few years back for a competition on another forum and its really just sat around collecting dust since then. Ask...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.