Jump to content

MySQL Query Timeout


johnslater

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/124559-mysql-query-timeout/
Share on other sites

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) ");

Link to comment
https://forums.phpfreaks.com/topic/124559-mysql-query-timeout/#findComment-643391
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.