Home >Backend Development >PHP Tutorial >A brief analysis of the maximum data amount supported by THINKPHP's addAll, thinkphpaddall_PHP tutorial
There are two methods for Model operation in Thinkphp: add() and addAll
The addAll method can add data in batches, which is how MySQL is used:
When the amount of data is large, try to insert in batches instead of inserting items one by one in a loop, otherwise your database will be overwhelmed and hang up.
However, if you take it for granted and store all the data into an array and perform addAll, you will also face a hang-up situation. Why is this?
The reason is that the configuration of the max_allowed_packet variable in mysql limits the length of the upload sql statement. Just configure it to be larger in the mysql configuration
max_allowed_packet = 100M
At the same time, when inserting data, also limit the length of batch insertion. After all, you never know when the data will become millions.
The above is the entire content of this article, I hope you guys will like it.