/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$pdo->beginTransaction(); //... $stmt = $pdo->prepare('INSERT INTO foo VALUES(:v1_1, :v1_2, :v1_3), (:v2_1, :v2_2, :v2_3), (:v2_1, :v2_2, :v2_3)'); $stmt->bindValue(':v1_1', $data[0][0]); $stmt->bindValue(':v1_2', $data[0][1]); $stmt->bindValue(':v1_3', $data[0][2]); //... $stmt->execute(); //or $stmt = $pdo->prepare('INSERT INTO foo VALUES(:a, :b, :c)'); foreach($data as $item) { $stmt->bindValue(':a', $item[0]); $stmt->bindValue(':b', $item[1]); $stmt->bindValue(':c', $item[2]); $stmt->execute(); } //... $pdo->commit();