Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!


Sponsored Content

 

 
 

Photo
- - - - -

Automatic Date Related Pruning


  • Please log in to reply
6 replies to this topic

#1 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 23 May 2008 - 08:16 PM

I have an accommodation availability and tariff page that is populated from a MYSQL table and would like to incorporate Automatic Pruning by date expiry from the table. What is the best way to accomplish this using PHP and MYSQL and my just about intermediate coding skills.

Thanks in advance for any help and guidance.

#2 chrishirst

chrishirst

    A not so moderate moderator.

  • Moderator
  • 5,881 posts
  • Location:Blackpool UK

Posted 24 May 2008 - 05:54 AM

DELETE FROM table WHERE datecolumn BETWEEN date1 AND date2 ;


or set/reset a flag to deactivate the entries.

#3 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 24 May 2008 - 06:57 PM

Chris, I would like to delete a date entry when the actual date passes the entered date.
Example: the entry for week begining Saturday 7th June should be automatically deleted when the actual date reaches the 8th June.

#4 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 24 May 2008 - 09:19 PM

Delete the whole database table entry or just the date field?

Either way you could do it with a simple MySQL delete statement as Chris laid out above, then set up a little cron job on a script to parse through the database table to figure out what needs to be deleted and what doesn't. Set up the server to fire it at 1am or something and you'd always be good to go without any daily hands on action.

#5 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 25 May 2008 - 05:31 AM

Thanks Randy and Chris, I will set about doing that in the next few days.

#6 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 25 May 2008 - 06:53 AM

One small heads up...

Figure out how the date is being set originally before you even dig into the coding aspect. There are different formats (eg php date is not necessarily the same as using a MySQL date function) and knowing what is used to set the date initially will save you a lot of heartburn.

#7 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 25 May 2008 - 10:12 AM

Thanks Randy, I am already on to that as I am trying to convert a Day+Month+Year set of dropdown inputs (Client Interface) into "Unixtime" which I already use to store a "lastupdated" field.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users