What is the best way to insert multiple rows in PHP PDO MYSQL?
You have at least these two options: $rows = [(1,2,3), (4,5,6), (7,8,9) … ]; $sql = “insert into `table_name` (col1, col2, col3) values (?,?,?)”; $stmt = $db->prepare($sql); foreach($rows as $row) { $stmt->execute($row); } OR: $rows = [(1,2,3), (4,5,6), (7,8,9) … ]; $sql = “insert into `table_name` (col1, col2, col3) values “; $paramArray = array(); $sqlArray … Read more