BulkInsertQuery

class \TYPO3\CMS\Core\Database\Query\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.

Tags

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

Table of Contents

Properties

$columns  : string[]
$connection  : Connection
$parameters  : array
$table  : string
$types  : array
$values  : array

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
Returns the parameters for this INSERT query being constructed indexed by parameter index.
getParameterTypes()  : array
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.

Properties

$connection

protected Connection $connection

$parameters

protected array $parameters = []

Methods

__construct()

Constructor.

public __construct(Connection $connection, string $table[, 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 : 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 $values[, array $types = [] ]) : mixed

Parameters

$values : array

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 = []

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

Return values

array

getParameterTypes()

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

public getParameterTypes() : array

Return values

array

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
On this page