Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member spasm attack's Avatar
    Join Date
    Aug 2006
    Location
    Colorado
    Posts
    15
    Member #
    13735
    Hey, I'm trying to write a shoutbox script. I only want it to display the last 10 messages, so I don't see the point in keeping more than 10 rows in the MySQL database. And also, popular websites can get hundreds of new messages in their shoutbox every day, so if you don't prune the table, it will be quite large after a couple of weeks. Is there some feature in MySQL that I don't know about that will automatically dump the oldest row out when inserting a new one? I can write a script that will do this manually if there isn't. I have also considered using a text file, but I'm paying for a database, so why not use it. If you know of a better way to do this, please share :classic:.

    On a side note, is it possible to get the server to run a certain php script every day at midnight? The only other alternative would be to do it on every page load :ermm:.
    "There is no spoone" -The Matricks

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    You could use a cron job to run a certain page daily, some hosts have limits on how frequent they can run but I think setting it as a day you should be safe.

    And for your table issue, you could have 2 indexes, one is the primary auto inc column and the other is a dummy column.

    The dummy column will store the same value as the auto inc column, but if you delete from the table, there will not be any gaps.

    As in, you have 5 rows, you delete the 5th row, when you insert a new row, the highest primary index will now be 5.

    However, what if you need to make a backup of the shoutbox? You will have no record of all the +10 shouts


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:32 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com