What is the best way to insert multiple rows in PHP PDO MYSQL?

后端 未结 4 1666
清歌不尽
清歌不尽 2020-12-03 21:14

Say, we have multiple rows to be inserted in a table:

$rows = [(1,2,3), (4,5,6), (7,8,9) ... ] //[ array of values ];

Using PDO:

         


        
4条回答
  •  醉梦人生
    2020-12-03 21:59

    You can also go this way:

    prepare($sql)->execute($vals);
    

    To be honest, I don't know which one will be faster, all depends on the delay between mysql and the php server.

提交回复
热议问题