Mysqli multi query error
PHP Snippet 1:
$data = [
['col1' => 'foo1', 'col2' => 'bar1'],
['col1' => 'foo2', 'col2' => 'bar2'],
];
// prepare SQL query once
$stmt = $mysqli->prepare("INSERT INTO table SET col1 = ?, col2 = ?");
$mysqli->begin_transaction();
// loop over the data array
foreach ($data as $row) {
$stmt->bind_param("ss", $row['col1'], $row['col2']);
$stmt->execute();
}
$mysqli->commit();