ConnectionPool
Manager that handles opening/retrieving database connections.
It's a facade to the actual Doctrine DBAL DriverManager that implements TYPO3 specific functionality like mapping individual tables to different database connections.
getConnectionForTable() is the only supported way to get a connection that honors the table mapping configuration.
Table of Contents
Constants
- DEFAULT_CONNECTION_NAME = 'Default'
Properties
- $connections : array<string|int, Connection>
- $customDoctrineTypes : array<non-empty-string, class-string>
- $overrideDoctrineTypes : array<non-empty-string, class-string>
Methods
- getConnectionByName() : Connection
- Creates a connection object based on the specified identifier.
- getConnectionForTable() : Connection
- Creates a connection object based on the specified table name.
- getConnectionMiddlewareConfigurationArrayForLowLevelConfiguration() : array<string|int, mixed>
- getConnectionNames() : array<string|int, mixed>
- Returns an array containing the names of all currently configured connections.
- getQueryBuilderForTable() : QueryBuilder
- Returns the connection specific query builder object that can be used to build complex SQL queries using and object-oriented approach.
- registerDoctrineTypes() : void
- Register custom and override Doctrine data types implemented by TYPO3.
- resetConnections() : void
- Reset internal list of connections.
- getConnectionParams() : array<string|int, mixed>
- getDatabaseConnection() : Connection
- Creates a connection object based on the specified parameters
- getDriverMiddlewares() : array<string|int, mixed>
- Return any doctrine driver middlewares, that may have been set up in: - for all configured connections - $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['driverMiddlewares'] for a specific connection
- getOrderedConnectionDriverMiddlewareConfiguration() : array<non-empty-string, array{target: class-string, disabled: bool, after: string[], before: string[], type: string}>
Constants
DEFAULT_CONNECTION_NAME
public
string
DEFAULT_CONNECTION_NAME
= 'Default'
Properties
$connections
protected
static array<string|int, Connection>
$connections
= []
$customDoctrineTypes
protected
array<non-empty-string, class-string>
$customDoctrineTypes
= [\TYPO3\CMS\Core\Database\Schema\Types\SetType::TYPE => \TYPO3\CMS\Core\Database\Schema\Types\SetType::class]
$overrideDoctrineTypes
protected
array<non-empty-string, class-string>
$overrideDoctrineTypes
= [\Doctrine\DBAL\Types\Types::DATE_MUTABLE => \TYPO3\CMS\Core\Database\Schema\Types\DateType::class, \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE => \TYPO3\CMS\Core\Database\Schema\Types\DateTimeType::class, \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE => \TYPO3\CMS\Core\Database\Schema\Types\DateTimeType::class, \Doctrine\DBAL\Types\Types::TIME_MUTABLE => \TYPO3\CMS\Core\Database\Schema\Types\TimeType::class]
Methods
getConnectionByName()
Creates a connection object based on the specified identifier.
public
getConnectionByName(string $connectionName) : Connection
This method should only be used in edge cases. Use getConnectionForTable() so that the tablename<>databaseConnection mapping will be taken into account.
Parameters
- $connectionName : string
Tags
Return values
ConnectiongetConnectionForTable()
Creates a connection object based on the specified table name.
public
getConnectionForTable(string $tableName) : Connection
This is the official entry point to get a database connection to ensure that the mapping of table names to database connections is honored.
Parameters
- $tableName : string
Return values
ConnectiongetConnectionMiddlewareConfigurationArrayForLowLevelConfiguration()
public
getConnectionMiddlewareConfigurationArrayForLowLevelConfiguration() : array<string|int, mixed>
only for ext:lowlevel
usage to retrieve configuration overview. *
Return values
array<string|int, mixed>getConnectionNames()
Returns an array containing the names of all currently configured connections.
public
getConnectionNames() : array<string|int, mixed>
This method should only be used in edge cases. Use getConnectionForTable() so that the tablename<>databaseConnection mapping will be taken into account.
Return values
array<string|int, mixed>getQueryBuilderForTable()
Returns the connection specific query builder object that can be used to build complex SQL queries using and object-oriented approach.
public
getQueryBuilderForTable(string $tableName) : QueryBuilder
Parameters
- $tableName : string
Return values
QueryBuilderregisterDoctrineTypes()
Register custom and override Doctrine data types implemented by TYPO3.
public
registerDoctrineTypes() : void
This method is needed by Schema parser to register the types as it does not require a database connection and thus the types don't get registered automatically.
resetConnections()
Reset internal list of connections.
public
resetConnections() : void
Currently, primarily used in functional tests to close connections and start new ones in between single tests.
getConnectionParams()
protected
getConnectionParams(string $connectionName) : array<string|int, mixed>
Parameters
- $connectionName : string
Return values
array<string|int, mixed>getDatabaseConnection()
Creates a connection object based on the specified parameters
protected
getDatabaseConnection(string $connectionName, array<string|int, mixed> $connectionParams) : Connection
Parameters
- $connectionName : string
- $connectionParams : array<string|int, mixed>
Return values
ConnectiongetDriverMiddlewares()
Return any doctrine driver middlewares, that may have been set up in: - for all configured connections - $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['driverMiddlewares'] for a specific connection
protected
getDriverMiddlewares(string $connectionName, array<string|int, mixed> $connectionParams) : array<string|int, mixed>
Parameters
- $connectionName : string
- $connectionParams : array<string|int, mixed>
Return values
array<string|int, mixed>getOrderedConnectionDriverMiddlewareConfiguration()
protected
getOrderedConnectionDriverMiddlewareConfiguration(string $connectionName, array<string|int, mixed> $connectionParams) : array<non-empty-string, array{target: class-string, disabled: bool, after: string[], before: string[], type: string}>
Parameters
- $connectionName : string
- $connectionParams : array<string|int, mixed>