Autodelete?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ganon

    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.


  • Jay Moore

    #2
    Re: Autodelete?

    Ganon wrote:
    [color=blue]
    > 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.
    >
    >[/color]

    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

    Comment

    • Ganon

      #3
      Re: Autodelete?

      cron?
      "Jay Moore" <address@isp.tl d> wrote in message
      news:qlF8c.729$ z%1.639@twister .rdc-kc.rr.com...[color=blue]
      > Ganon wrote:
      >[color=green]
      > > I have a database where I'm storing some user information, but I only[/color][/color]
      want[color=blue][color=green]
      > > the entries to remain in the database for a certain amount of time (say[/color][/color]
      72[color=blue][color=green]
      > > hours). I have a datetime field in my database so I can manually tell,[/color][/color]
      but[color=blue][color=green]
      > > obviously that will be a real headache.
      > >
      > > I thought maybe I could do some php in a private script to search[/color][/color]
      through[color=blue][color=green]
      > > the database and delete rows where time has expired, but not sure really[/color][/color]
      how[color=blue][color=green]
      > > 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.
      > >
      > >[/color]
      >
      > 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
      >[/color]


      Comment

      • Justin Koivisto

        #4
        Re: Autodelete?

        Jay Moore wrote:
        [color=blue]
        > Ganon wrote:
        >[color=green]
        >> 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.
        >>
        >>[/color]
        >
        > 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.[/color]

        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.ph p"></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.ph p" 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 - spam@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/

        Comment

        • Jay Moore

          #5
          Re: Autodelete?

          Ganon wrote:
          [color=blue]
          > cron?
          > "Jay Moore" <address@isp.tl d> wrote in message
          > news:qlF8c.729$ z%1.639@twister .rdc-kc.rr.com...
          >[color=green]
          >>Ganon wrote:
          >>
          >>[color=darkred]
          >>>I have a database where I'm storing some user information, but I only[/color][/color]
          >
          > want
          >[color=green][color=darkred]
          >>>the entries to remain in the database for a certain amount of time (say[/color][/color]
          >
          > 72
          >[color=green][color=darkred]
          >>>hours). I have a datetime field in my database so I can manually tell,[/color][/color]
          >
          > but
          >[color=green][color=darkred]
          >>>obviously that will be a real headache.
          >>>
          >>>I thought maybe I could do some php in a private script to search[/color][/color]
          >
          > through
          >[color=green][color=darkred]
          >>>the database and delete rows where time has expired, but not sure really[/color][/color]
          >
          > how
          >[color=green][color=darkred]
          >>>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.
          >>>
          >>>[/color]
          >>
          >>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
          >>[/color]
          >
          >
          >[/color]

          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

          Comment

          • Chung Leong

            #6
            Re: Autodelete?

            Uzytkownik "Ganon" <evillordganon@ hotmail.com> napisal w wiadomosci
            news:ZeD8c.1553 6$1x2.12912@new s-binary.blueyond er.co.uk...[color=blue]
            > 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[/color]
            how[color=blue]
            > that would work.
            >
            > Also, I doubt it... but is there are way to set up mySQL entries to
            > autodelete after a certain time?
            >[/color]

            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.


            Comment

            Working...