Yeah, I thought of setting up a cron job, maybe to fire at midnight or something like that - to delete the records. It's a messaging system. I have shell access on my server; I turn it on and off for domains so I don't get invaded (it's happened).
I was thinking either that, or every time the data is queried it could delte, but if it's a load on MySQL to do that, then the cron job is the better alternative. Thanks. Marian --- In [email protected], James Keeline <[EMAIL PROTECTED]> wrote: > --- Marian Briones <[EMAIL PROTECTED]> wrote: > > Is it possible to have records go away in a MySQL table after a given > > amount of days have passed? Or should I tackle it as a by product of > > a script that retrieves records from it? (The first part of it would > > go and delete records older than a given date, based on the current > > date using the date() functions in php to get the current date and > > THEN display the remaining records). > > > > I have to read up on calculating dates with the date field in MySQL > > but I can do that on my own. Just wondering if there is an auto > > expire available in MySQL. > > > > Thanks, gang. > > > > Marian > > With the very latest version of MySQL (4.1.x) there may be a way of setting up > a trigger and a stored procedure to do what you want. > > However, it is often more straightforward to perform a query to delete old > records either on a periodic basis (via a cron job in Unix/Linux) or each time > your visitors make a request. > > I prefer the cron job method but it may not be right for you depending on the > type of access you have to your server. It is usually necessary to have a > command-line connection to set up the cron jobs. > > The second method could be a problem if your site is very busy and you will be > attempting to delete records often. Remember that MySQL is lightning fast for > most SELECT queries but is slower for INSERT and UPDATE queries. > > In one system I created, I needed to update a particular table before a search > was performed. I was able to perform the UPDATE before displaying the search > form and the tables were small enough that this was done very quickly. > > James > _____ > > > James D. Keeline > http://www.Keeline.com http://www.Keeline.com/articles > http://Stratemeyer.org http://www.Keeline.com/TSCollection > > http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc. > Spring Semester Begins Jan 31 -- New Classes Start Every Few Weeks. Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
