gpt4 book ai didi

php - 高效的 MySQL INSERT

转载 作者:行者123 更新时间:2023-11-29 01:05:44 26 4
gpt4 key购买 nike

<分区>

我有一个 PHP 脚本,我要将值插入到 MySQL 表中。这在处理几千行数据时工作正常,但随着我增加数据,只有一部分数据被插入到 MySQL 表中。

它似乎只在大约 6000 行数据后停止。我真的希望它能处理 40,000 行,后来它需要 160,000 行。我必须多次运行脚本才能将更多数据添加到表中。

我刚开始使用 SQL 语句,我认为我设置它的方式效率不高。

我的一些代码:

for($x=0;$x<count($array_athlete); $x++){

$checkuser=mysqli_query($link,"SELECT * FROM `Events_testing2` WHERE `location`='$location'
AND `barcode`='$array_barcode[$x]' AND `date`='$date'");
$rowcount=mysqli_num_rows($checkuser); //checks if barcode exists for that user in that location on that date. Inserts data if doesn't already exist.

if($rowcount>0){
}
else{
$queryInsertUser=mysqli_query($link, "INSERT INTO `Events_testing2` (`eventID`,`location`,`date`,`barcode`,`athlete`,`time`,`Run Points`,`Volunteer Points`,`Gender`,`Gender pos`)
VALUES (' ','$location','$date','$array_barcode[$x]','$array_athlete[$x]','$array_time[$x]','$array_score[$x]',' ','$array_gender[$x]','$array_gender_pos[$x]') ");

}
}

任何有关如何快速将更多行插入数据库的建议都将不胜感激。
非常感谢

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com