php - Cannot call more than 100 INSERT queries -
i have insert 1000 records read file , insert db code not working more 100 times. says internal server 500
works fine when run code below 100 times. there settings have apply insert more 100 records?
here code:
<?php $servername = "**"; $username = "**"; $password = "**"; $dbname = "**"; $con=mysqli_connect($servername, $username, $password,$dbname); for($i=0; $i<400; $i++){ $query = mysqli_query($con,"insert table_name (column1, column2, column3) values (value1, value2, value3)"); } $query->close(); $con->close(); ?>
it's working 100 times. if set loop run more than that, not work ideas?
i unsure if eliminate issue, better try reduce total database calls in code.
since inserting on same table, can in single query. build single query inside loop , use mysqli_query()
once after loop finished.
code:
$values=""; for($i=0; $i<400; $i++){ $values.=($i==0?"",",")."('value1','value2','value3')"; } $query=mysqli_query($con,"insert table_name (column1, column2, column3) values $values;
Comments
Post a Comment