• 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

Which is faster php date functions or carbon?

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

Laravel Route issues with Route order in web.php

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

How Can I Do LIMIT 1, 2 In WP_Query

MySQL upgrade causing unexpected results on simple WHERE clauses

Merge column values from two arrays to form an indexed array of associative arrays

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

how to retrieve the first and last instance of a row in pdo dataset

How to load Codeigniter 4 lang file into an array variable

(Laravel) How to delete multiple models including optional relationships?

Laravel print last executed SQL query with Query log

How to get transaction details in notify_url page in paypal

Wordpress wpdb->delete issue

About Contact Privacy policy Terms and conditions