BulkInsertQuery

Provides functionality to generate and execute row based bulk INSERT statements.

Based on work by Steve Müller st.mueller@dzh-online.de for the Doctrine project, licensed under the MIT license.

This class will be removed from core and the functionality will be provided by the upstream implementation once the pull request has been merged into Doctrine DBAL.

Internal
Tags
see
https://github.com/doctrine/dbal/pull/682

Table of Contents

Properties

$columns  : array<string|int, string>
$connection  : Connection
$parameters  : array<string|int, mixed>
$table  : string
$types  : array<string|int, mixed>
$values  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructor.
__toString()  : string
Render the bulk insert statement as string.
addValues()  : mixed
Adds a set of values to the bulk insert query to be inserted as a row into the specified table.
execute()  : int
Executes this INSERT query using the bound parameters and their types.
getParameters()  : array<string|int, mixed>
Returns the parameters for this INSERT query being constructed indexed by parameter index.
getParameterTypes()  : array<string|int, mixed>
Returns the parameter types for this INSERT query being constructed indexed by parameter index.
getSQL()  : string
Returns the SQL formed by the current specifications of this INSERT query.
getInsertMaxRows()  : int
Return the maximum number of rows that can be inserted at the same time.

Properties

$columns

protected array<string|int, string> $columns

$connection

protected Connection $connection

$parameters

protected array<string|int, mixed> $parameters = []

$types

protected array<string|int, mixed> $types = []

$values

protected array<string|int, mixed> $values = []

Methods

__construct()

Constructor.

public __construct(Connection $connection, string $table[, array<string|int, string> $columns = [] ]) : mixed
Parameters
$connection : Connection

The connection to use for query execution.

$table : string

The name of the table to insert rows into.

$columns : array<string|int, string> = []

The names of the columns to insert values into. Can be left empty to allow arbitrary row inserts based on the table's column order.

__toString()

Render the bulk insert statement as string.

public __toString() : string
Return values
string

addValues()

Adds a set of values to the bulk insert query to be inserted as a row into the specified table.

public addValues(array<string|int, mixed> $values[, array<string|int, mixed> $types = [] ]) : mixed
Parameters
$values : array<string|int, mixed>

The set of values to be inserted as a row into the table. If no columns have been specified for insertion, this can be an arbitrary list of values to be inserted into the table. Otherwise the values' keys have to match either one of the specified column names or indexes.

$types : array<string|int, mixed> = []

The types for the given values to bind to the query. If no columns have been specified for insertion, the types' keys will be matched against the given values' keys. Otherwise the types' keys will be matched against the specified column names and indexes. Non-matching keys will be discarded, missing keys will not be bound to a specific type.

Tags
throws
InvalidArgumentException

if columns were specified for this query and either no value for one of the specified columns is given or multiple values are given for a single column (named and indexed) or multiple types are given for a single column (named and indexed).

execute()

Executes this INSERT query using the bound parameters and their types.

public execute() : int
Tags
throws
LogicException

if this query contains more rows than acceptable for a single INSERT statement by the underlying platform.

Return values
int

The number of affected rows.

getParameters()

Returns the parameters for this INSERT query being constructed indexed by parameter index.

public getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getParameterTypes()

Returns the parameter types for this INSERT query being constructed indexed by parameter index.

public getParameterTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSQL()

Returns the SQL formed by the current specifications of this INSERT query.

public getSQL() : string
Tags
throws
LogicException

if no values have been specified yet.

Return values
string

getInsertMaxRows()

Return the maximum number of rows that can be inserted at the same time.

protected getInsertMaxRows() : int
Return values
int

        
On this page

Search results