SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to avoid Maximum execution error

    Hi,
    I have a loop which inserts data to database .I need to insert 500 records one by one in a loop.

    <?
    for($i=0;$i<500;$i++){
    ---values insert into db
    }
    ?>

    After 30 -40 records inserting i am getting maximum execution error. Is there any alternative to handle this situation.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    set_time_limit()

    although you can insert more than 1 record in a single query, which might be highly preferable.
    eg

    insert into table (foo, bar) values (1,2), (3,4), (5,6) etc...

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks iam trying to set time limit

  4. #4
    SitePoint Addict
    Join Date
    Jan 2007
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the error states that there is a max for the database user you could try creating multiple user accounts and cycling through them.

  5. #5
    *********! *********!!! jackli's Avatar
    Join Date
    Sep 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why does the maximum execution error occur?

    suppose 40 different users wre to access the same mysql script at the same time, would max execution error occur?

  6. #6
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jackli View Post
    suppose 40 different users wre to access the same mysql script at the same time, would max execution error occur?
    If this resulted in some of them executing for more than specified time limit, then yes. Else, no.

  7. #7
    *********! *********!!! jackli's Avatar
    Join Date
    Sep 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what about for DELETE
    if you want to delete multiple rows at once, do you just do

    delete from table where col1='this' OR col2='that' OR col3='dis"


    is there something better htan OR to use for multiple deletes?

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ... where column IN ('this',that',dis')

    i dont know what the speed difference is.


Bookmarks

Posting Permissions

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