Batch inserts with PHP

前端 未结 2 372
野趣味
野趣味 2021-01-23 21:21

Java has the PreparedStatement addBatch + executeBatch to do multiple insertions efficiently.

What is the fasted way to do a batch of inserts using php\'s mysqli extensi

2条回答
  •  庸人自扰
    2021-01-23 22:09

    I realize this question is old, but for anyone else that comes across this, I found some useful information on this topic here: insert multiple rows via a php array into mysql.

    Depending on your needs, it may be fastest to pipe the data as csv directly into LOAD DATA INFILE. However, be very cautious with this approach as it offers no protection against injection attacks.

    I have used this approach in the past, validating the data cleanliness during csv generation.

提交回复
热议问题