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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2013
    Posts
    76
    Thanks
    19
    Thanked 1 Time in 1 Post

    DB Query Increments?

    I have a database of about 1000 users that I want to send an email to, unfortunately the server times out when trying to send it to this many people. So is there a way to do it in increments of let's say 10 or 20?

    I was thinking if there was a way to break it up and show checkboxes for the user to select which group to send. So one group would be a checkbox with 1-20, and then another checkbox would be 21-40, etc...

    Unfortunately I have no idea how this would even be accomplished, if it can be.

    Any thoughts on this?

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,450
    Thanks
    23
    Thanked 631 Times in 630 Posts
    You might want to try this from the php manual
    void set_time_limit ( int $seconds )

    Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.

    When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.
    Or if your server does not allow set_time_limit() you can set up cron jobs to send to groups at a set time for each (??? did you understand that?)


    P.S. just noticed your talking DB time out. If you just get the address and put them into a list and work from that the db time out should be avoided.
    Last edited by sunfighter; 11-04-2013 at 07:18 PM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,354
    Thanks
    61
    Thanked 529 Times in 516 Posts
    Quote Originally Posted by cgdtalent View Post
    I have a database of about 1000 users that I want to send an email to, unfortunately the server times out when trying to send it to this many people. So is there a way to do it in increments of let's say 10 or 20?

    I was thinking if there was a way to break it up and show checkboxes for the user to select which group to send. So one group would be a checkbox with 1-20, and then another checkbox would be 21-40, etc...

    Unfortunately I have no idea how this would even be accomplished, if it can be.

    Any thoughts on this?
    You can use set_time_limit but some server configs (shared servers for example) will have this function disabled so that you can't use it. If thats the case, copy out all of the addresses into another temporary table and then use a cron job to email 10 addresses at a time. Once each address has been emailed you can delete it from the temporary table.

    Failing that, if you want some sort of progress indicator you could just create a webpage that is interactive with ajax. It polls a script every second causing the script to email the next address in the DB and return it's result. You can then update the page to show it's progress.

    Quote Originally Posted by PluginDropout View Post
    I can build this for you but I would have the charge for my time. If your interested send me a IM with your price quote we can work something out, of course I would own the license to the product I then would just be leasing it out to you.
    I think you need to stop touting for business in the php forum. There is a jobs / projects forum you should be posting in. As for owning the code and then leasing it back, get real. Coding and then selling it to the webmaster is one thing but leasing it to them? - on a forum that offers FREE solutions?

    Quote Originally Posted by sunfighter View Post
    P.S. just noticed your talking DB time out. If you just get the address and put them into a list and work from that the db time out should be avoided.
    I may be going blind but I didn't see the op specifically mention the DB timing out. They mention the server timing out and I can only assume that this is the php config.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,450
    Thanks
    23
    Thanked 631 Times in 630 Posts
    I may be going blind but I didn't see the op specifically mention the DB timing out. They mention the server timing out and I can only assume that this is the php config.
    That's what I thought when I gave him the same advice that you did and then I closed out and saw the title with mentions DB Query Increments?
    Not sure what that means, but added some thoughts if the php timed out during the db queries. Highly doubtful but who knows what he's doing to get the info from the db.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,354
    Thanks
    61
    Thanked 529 Times in 516 Posts
    I think the op means that they're wanting to increment through the records that they've emailed. I agree the title could be a bit more helpful really but some folks will use a confusing title to entice more people to read the topic (and thus possibly generating more help). What they don't realise is that it makes it harder and more confusing for anyone who might have helped
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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