• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Mysqli multi query error

phpmysqli


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();

Related Snippets

Printing more than one array using print_r or any other function in php

PHP usort() order in case of equality

How to remove Deprecated SymfonyComponentDebugDebugClassLoader?

carbon generated datetime not stored correctly into the database

Access denied for user 'homestead'@'localhost' (using password: YES)

How can I get data from PHP to Android TextView?

woocommerce change position of price

How do I set the maximum php memory limit

Chunk and transpose a flat array into rows with a specific number of columns

How to convert a carbon into string, to take the date only?

SilverStripe unable to populate multiple member Childs

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Laravel query builder binding parameters more than once

Sum array values of a column within each column of an array with 3 levels

How to get array values using foreach in laravel

About Contact Privacy policy Terms and conditions