Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts

    run query 1 hour after insert

    would a cron be the best way to run a query about a hour after its inserted?

    for instance, someone signs up, they get a email to enter feed back a hour later.

    any ideas besides cron or is that the best way?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,864
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    would a cron be the best way to run a query about a hour after its inserted?

    for instance, someone signs up, they get a email to enter feed back a hour later.
    I think so. Make a cron to fetch all such users from DB for sending the emails.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    I think this is the only way you'll be able to do it really
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #4
    Regular Coder byuhobbes85's Avatar
    Join Date
    Oct 2006
    Location
    Ames, Iowa, USA
    Posts
    116
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Yeah, I would have a single script that ran every minute (or 5 minutes or 15 minutes, depending on how close to an hour you want it to be). I would make sure there are two fields in the database--time of sign up and a flag indicating whether they have received an email. The script that runs every minute (or 5 or 15) would then check to see if there were any sign ups that occurred at least an hour ago that had not yet received an email, and then send an email to those people and update the database.

    Hope this helps.
    -- </byuhobbes>

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    I'd advise every 15 mins personally. You'll just be running more queries than required otherwise IMO
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #6
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    You could also run it as a pseudo cron and just include the cron script at the end of your page.

  • #7
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    thanks for the heads up guys, guess its cron


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •