johnslater Posted September 16, 2008 Share Posted September 16, 2008 I'm running a PHP script that runs through an array containg quite a few records. This array has each row outputted and then this row is placed into the database. The problem is MySQL decides to stop half way through the query and say "MySQL has gone away" or "Lost connection to MySQL server during query" meaning nothing every gets entered into the database anyway. Don't suppose there is a way to split the query so it only inserts 100 at a time rather than trying to get all of them in? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 16, 2008 Share Posted September 16, 2008 instead of mysql_query("INSERT INTO tablename (a,b,c) VALUES (x1,y1,z1)"); mysql_query("INSERT INTO tablename (a,b,c) VALUES (x2,y2,z2)"); mysql_query("INSERT INTO tablename (a,b,c) VALUES (x3,y3,z3)"); try the faster version mysql_query("INSERT INTO tablename (a,b,c) VALUES (x1,y1,z1), (x2,y2,z2), (x3,y3,z3) "); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.