For this large amount of data insertion method, if the online business is not so busy, you can consider inserting in batches. After batch inserting, the returned result is the number of affected rows. The returned results are easier to search and the efficiency will be higher than this. Or business, simple violence.
//Define variable num
$num = 0;
while (! feof($file)) {
}
// Judge the value of num here
if ($num == 0) {
} else {
}
Start the transaction
transaction
, and as long as there is an error, it willrollback
and throw an exceptionAfter the insertion is successful, data will be returned. Just make a judgment based on the return! !
For this large amount of data insertion method, if the online business is not so busy, you can consider inserting in batches. After batch inserting, the returned result is the number of affected rows. The returned results are easier to search and the efficiency will be higher than this. Or business, simple violence.
It is recommended to use things, so that you can at least ensure the consistency of the data.