Connection extends Connection implements LoggerAwareInterface uses LoggerAwareTrait
Table of Contents
Interfaces
- LoggerAwareInterface
Constants
- PARAM_BOOL = \Doctrine\DBAL\ParameterType::BOOLEAN
- Represents a boolean data type.
- PARAM_INT = \Doctrine\DBAL\ParameterType::INTEGER
- Represents a SQL INTEGER data type.
- PARAM_INT_ARRAY = \Doctrine\DBAL\ArrayParameterType::INTEGER
- Represents an array of integer values.
- PARAM_LOB = \Doctrine\DBAL\ParameterType::LARGE_OBJECT
- Represents a SQL large object data type.
- PARAM_NULL = \Doctrine\DBAL\ParameterType::NULL
- Represents a SQL NULL data type.
- PARAM_STR = \Doctrine\DBAL\ParameterType::STRING
- Represents a SQL CHAR, VARCHAR data type.
- PARAM_STR_ARRAY = \Doctrine\DBAL\ArrayParameterType::STRING
- Represents an array of string values.
Methods
- __construct() : mixed
- Initializes a new instance of the Connection class.
- bulkInsert() : int
- Bulk inserts table rows with specified data.
- count() : int
- Executes an SQL SELECT COUNT() statement on a table and returns the count result.
- createQueryBuilder() : QueryBuilder
- Creates a new instance of a SQL query builder.
- delete() : int
- Executes an SQL DELETE statement on a table.
- escapeLikeWildcards() : string
- Quotes like wildcards for given string value.
- getExpressionBuilder() : ExpressionBuilder
- Gets the ExpressionBuilder for the connection.
- getPlatformServerVersion() : string
- Returns the version of the current platform if applicable, containing the platform as prefix.
- getSchemaInformation() : SchemaInformation
- insert() : int
- Inserts a table row with specified data.
- lastInsertId() : numeric-string
- Returns the ID of the last inserted row.
- prepareConnection() : void
- Execute commands after initializing a new connection.
- quoteColumnValuePairs() : array<string|int, mixed>
- Quotes an associative array of column-value so the column names can be safely used, even if the name is a reserved name.
- quoteIdentifier() : string
- Quotes a string so it can be safely used as a table or column name, even if it is a reserved name.
- quoteIdentifiers() : array<string|int, mixed>
- Quotes an array of column names, so it can be safely used, even if the name is a reserved name.
- select() : Result
- Executes an SQL SELECT statement on a table.
- truncate() : int
- Executes an SQL TRUNCATE statement on a table.
- update() : int
- Executes an SQL UPDATE statement on a table.
- connect() : Connection
- Gets the DatabasePlatform for the connection and initializes custom types and event listeners.
- ensureDatabaseValueTypes() : void
- This method ensures that data values a properly converted to their database equivalent.
- quoteColumnTypes() : array<string|int, mixed>
- Detect if the column types are specified by column name or using positional information. In the first case quote the field names accordingly.
Constants
PARAM_BOOL
Represents a boolean data type.
public
mixed
PARAM_BOOL
= \Doctrine\DBAL\ParameterType::BOOLEAN
PARAM_INT
Represents a SQL INTEGER data type.
public
mixed
PARAM_INT
= \Doctrine\DBAL\ParameterType::INTEGER
PARAM_INT_ARRAY
Represents an array of integer values.
public
mixed
PARAM_INT_ARRAY
= \Doctrine\DBAL\ArrayParameterType::INTEGER
PARAM_LOB
Represents a SQL large object data type.
public
mixed
PARAM_LOB
= \Doctrine\DBAL\ParameterType::LARGE_OBJECT
PARAM_NULL
Represents a SQL NULL data type.
public
mixed
PARAM_NULL
= \Doctrine\DBAL\ParameterType::NULL
PARAM_STR
Represents a SQL CHAR, VARCHAR data type.
public
mixed
PARAM_STR
= \Doctrine\DBAL\ParameterType::STRING
PARAM_STR_ARRAY
Represents an array of string values.
public
mixed
PARAM_STR_ARRAY
= \Doctrine\DBAL\ArrayParameterType::STRING
Methods
__construct()
Initializes a new instance of the Connection class.
public
__construct(array<string|int, mixed> $params, Driver $driver[, Configuration|null $config = null ]) : mixed
Parameters
- $params : array<string|int, mixed>
-
The connection parameters.
- $driver : Driver
-
The driver to use.
- $config : Configuration|null = null
-
The configuration, optional.
bulkInsert()
Bulk inserts table rows with specified data.
public
bulkInsert(string $tableName, array<string|int, mixed> $data[, array<string|int, mixed> $columns = [] ][, array<string|int, mixed> $types = [] ]) : int
All SQL identifiers are expected to be unquoted and will be quoted when building the query.
Parameters
- $tableName : string
-
The name of the table to insert data into.
- $data : array<string|int, mixed>
-
An array containing associative arrays of column-value pairs or just the values to be inserted.
- $columns : array<string|int, mixed> = []
-
An array containing the column names of the data which should be inserted.
- $types : array<string|int, mixed> = []
-
Types of the inserted data.
Return values
int —The number of affected rows.
count()
Executes an SQL SELECT COUNT() statement on a table and returns the count result.
public
count(string $item, string $tableName, array<string|int, mixed> $identifiers) : int
Parameters
- $item : string
-
The column/expression of the table which to count
- $tableName : string
-
The name of the table on which to count.
- $identifiers : array<string|int, mixed>
-
The selection criteria. An associative array containing column-value pairs.
Return values
int —The number of rows counted
createQueryBuilder()
Creates a new instance of a SQL query builder.
public
createQueryBuilder() : QueryBuilder
Return values
QueryBuilderdelete()
Executes an SQL DELETE statement on a table.
public
delete(string $tableName[, array<string|int, mixed> $identifier = [] ][, array<string|int, mixed> $types = [] ]) : int
All SQL identifiers are expected to be unquoted and will be quoted when building the query.
Parameters
- $tableName : string
-
The name of the table on which to delete.
- $identifier : array<string|int, mixed> = []
-
The deletion criteria. An associative array containing column-value pairs.
- $types : array<string|int, mixed> = []
-
The types of identifiers.
Return values
int —The number of affected rows.
escapeLikeWildcards()
Quotes like wildcards for given string value.
public
escapeLikeWildcards(string $value) : string
Parameters
- $value : string
-
The value to be quoted.
Return values
string —The quoted value.
getExpressionBuilder()
Gets the ExpressionBuilder for the connection.
public
getExpressionBuilder() : ExpressionBuilder
Return values
ExpressionBuildergetPlatformServerVersion()
Returns the version of the current platform if applicable, containing the platform as prefix.
public
getPlatformServerVersion() : string
If no version information is available only the platform name will be shown. If the platform name is unknown or unsupported the driver name will be shown.
only and not part of public API.
Return values
stringgetSchemaInformation()
public
getSchemaInformation() : SchemaInformation
May vanish anytime, currently used core-internal at some places.
Return values
SchemaInformationinsert()
Inserts a table row with specified data.
public
insert(string $tableName, array<string|int, mixed> $data[, array<string|int, mixed> $types = [] ]) : int
All SQL identifiers are expected to be unquoted and will be quoted when building the query.
Parameters
- $tableName : string
-
The name of the table to insert data into.
- $data : array<string|int, mixed>
-
An associative array containing column-value pairs.
- $types : array<string|int, mixed> = []
-
Types of the inserted data.
Return values
int —The number of affected rows.
lastInsertId()
Returns the ID of the last inserted row.
public
lastInsertId() : numeric-string
If the underlying driver does not support identity columns, an exception is thrown.
Return values
numeric-stringprepareConnection()
Execute commands after initializing a new connection.
public
prepareConnection(string $commands) : void
Parameters
- $commands : string
quoteColumnValuePairs()
Quotes an associative array of column-value so the column names can be safely used, even if the name is a reserved name.
public
quoteColumnValuePairs(array<string|int, mixed> $input) : array<string|int, mixed>
Delimiting style depends on the underlying database platform that is being used.
Parameters
- $input : array<string|int, mixed>
Return values
array<string|int, mixed>quoteIdentifier()
Quotes a string so it can be safely used as a table or column name, even if it is a reserved name.
public
quoteIdentifier(string $identifier) : string
EXAMPLE: tableName.fieldName => "tableName"."fieldName"
Delimiting style depends on the underlying database platform that is being used.
Parameters
- $identifier : string
-
The name to be quoted.
Return values
string —The quoted name.
quoteIdentifiers()
Quotes an array of column names, so it can be safely used, even if the name is a reserved name.
public
quoteIdentifiers(array<string|int, mixed> $input) : array<string|int, mixed>
Delimiting style depends on the underlying database platform that is being used.
Parameters
- $input : array<string|int, mixed>
Return values
array<string|int, mixed>select()
Executes an SQL SELECT statement on a table.
public
select(array<string|int, string> $columns, string $tableName[, array<string|int, mixed> $identifiers = [] ][, array<string|int, string> $groupBy = [] ][, array<string|int, mixed> $orderBy = [] ][, int $limit = 0 ][, int $offset = 0 ]) : Result
All SQL identifiers are expected to be unquoted and will be quoted when building the query.
Parameters
- $columns : array<string|int, string>
-
The columns of the table which to select.
- $tableName : string
-
The name of the table on which to select.
- $identifiers : array<string|int, mixed> = []
-
The selection criteria. An associative array containing column-value pairs.
- $groupBy : array<string|int, string> = []
-
The columns to group the results by.
- $orderBy : array<string|int, mixed> = []
-
Associative array of column name/sort directions pairs.
- $limit : int = 0
-
The maximum number of rows to return.
- $offset : int = 0
-
The first result row to select (when used with limit)
Return values
Result —The executed statement.
truncate()
Executes an SQL TRUNCATE statement on a table.
public
truncate(string $tableName[, bool $cascade = false ]) : int
All SQL identifiers are expected to be unquoted and will be quoted when building the query.
Parameters
- $tableName : string
-
The name of the table to truncate.
- $cascade : bool = false
-
Not supported on many platforms but would cascade the truncate by following foreign keys.
Return values
int —The number of affected rows. For a truncate this is unreliable as there is no meaningful information.
update()
Executes an SQL UPDATE statement on a table.
public
update(string $tableName, array<string|int, mixed> $data[, array<string|int, mixed> $identifier = [] ][, array<string|int, mixed> $types = [] ]) : int
All SQL identifiers are expected to be unquoted and will be quoted when building the query.
Parameters
- $tableName : string
-
The name of the table to update.
- $data : array<string|int, mixed>
-
An associative array containing column-value pairs.
- $identifier : array<string|int, mixed> = []
-
The update criteria. An associative array containing column-value pairs.
- $types : array<string|int, mixed> = []
-
Types of the merged $data and $identifier arrays in that order.
Return values
int —The number of affected rows.
connect()
Gets the DatabasePlatform for the connection and initializes custom types and event listeners.
protected
connect() : Connection
Return values
ConnectionensureDatabaseValueTypes()
This method ensures that data values a properly converted to their database equivalent.
protected
ensureDatabaseValueTypes(string $tableName, array<string|int, mixed> &$data, array<string|int, mixed> &$types) : void
Additionally, it adds the proper types to the type-array, if this has no manual preset types. Note: Types are only added if not given externally.
Parameters
- $tableName : string
- $data : array<string|int, mixed>
- $types : array<string|int, mixed>
Should be private, but mocked in tests currently.
quoteColumnTypes()
Detect if the column types are specified by column name or using positional information. In the first case quote the field names accordingly.
protected
quoteColumnTypes(array<string|int, mixed> $input) : array<string|int, mixed>
Parameters
- $input : array<string|int, mixed>