multipleInsert

Performs one query to insert multiple records.

Parameters

multipleInsert($table, array $col_name, array $values)
$table:Name of the table to insert the data.
$col_name:Array containing the name of the columns.
$values:Multidimensional Array containing the values.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?php

require_once 'dalmp.php';

$user = getenv('MYSQL_USER') ?: 'root';
$password = getenv('MYSQL_PASS') ?: '';

$DSN = "utf8://$user:$password".'@127.0.0.1/test';

$db = new DALMP\Database($DSN);

$values = array(
    array(1,2,3),
    array(1,3),
    array('date','select', 3),
    array('niño','coraçao', 'Ú'),
    array(null,5,7)
);

$rs = $db->multipleInsert('tests', array('col1', 'col2', 'col3'), $values);

Note

The multipleInsert method uses Prepared statements PExecute to Insert the data.

Thanks Navicat for supporting Open Source projects.

Navicat



A great amount of time has been spent creating, crafting and maintaining this software, please consider donating.

Donating helps ensure continued support, development and availability.

dalmp


comments powered by Disqus