How to improve execution efficiency
for ($i =0; $i
{
$var = Explode (",", $r [$i]);
$barcode = $var [0];
$num = $var [1];
$sql = "INSERT into". $t. " ' (Barcode,num) VALUES (' ". $barcode." ', ' ". $num." ') ";
echo $sql. '
';
mysql_query ($sql);
}
A total of more than 6,000 records, if each record is executed insert into, consumes a long time, more than the default of 90s. Is there any way to improve execution efficiency?
Share to:
------Solution--------------------
You can insert an array into an array first, and then insert it uniformly
for ($i =0; $i
{
$var = Explode (",", $r [$i]);
$barcode = $var [0];
$num = $var [1];
$sql [] = "('". $barcode. "', '". $num. "')"; /write to SQL array
}
mysql_query (' insert INTO '. $t. ' (barcode,num) values '. Implode (', ', $sql));
Unified Insert
------Solution--------------------
Citation:
error message:
Maximum execution time of seconds exceeded
Time-outs can be added on top of the head
Set_time_limit (0);
?>