ConnectionPool
class \
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.
Attributes
- #[Autoconfigure]
- $public: true
Table of Contents
Constants
- DEFAULT_CONNECTION_NAME : string = 'Default'
Properties
- $connections : Connection[]
- $container : ContainerInterface
- $coreSchemaManagerFactory : CoreSchemaManagerFactory
- $customDoctrineTypes : array<non-empty-string, class-string>
- $driverMiddlewareService : DriverMiddlewareService
- $overrideDoctrineTypes : array<non-empty-string, class-string>
Methods
- __construct() : mixed
- 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
- getConnectionNames() : array
- Returns an array containing the names of all currently configured connections.
- getOpenConnectionNames() : array<int, non-empty-string>
- Returns the names of all connections that have already been instantiated in this pool. In contrast to getConnectionNames() this excludes configured but not yet used connections, so callers - for example the messenger worker middlewares pinging or closing connections - do not need to open connections just to act on them.
- 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
- Used to be used by functional tests to close statically stored connections, in order to use new connection in between single tests.
- getConnectionParams() : array
- getDatabaseConnection() : Connection
- Creates a connection object based on the specified parameters
- getDriverMiddlewares() : array
- 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
Connection[]
$connections
= []
$container read-only
protected
ContainerInterface
$container
$coreSchemaManagerFactory read-only
protected
CoreSchemaManagerFactory
$coreSchemaManagerFactory
$customDoctrineTypes
protected
static array<non-empty-string, class-string>
$customDoctrineTypes
= [\TYPO3\CMS\Core\Database\Schema\Types\SetType::TYPE => \TYP…Show the full value
[\TYPO3\CMS\Core\Database\Schema\Types\SetType::TYPE => \TYPO3\CMS\Core\Database\Schema\Types\SetType::class]
Tags
$driverMiddlewareService read-only
protected
DriverMiddlewareService
$driverMiddlewareService
$overrideDoctrineTypes
protected
static array<non-empty-string, class-string>
$overrideDoctrineTypes
= [\Doctrine\DBAL\Types\Types::DATE_MUTABLE => \TYPO3\CMS\Core…Show the full value
[\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]
Tags
Methods
__construct()
public
__construct(ContainerInterface $container, CoreSchemaManagerFactory $coreSchemaManagerFactory, DriverMiddlewareService $driverMiddlewareService) : mixed
Parameters
- $container : ContainerInterface
- $coreSchemaManagerFactory : CoreSchemaManagerFactory
- $driverMiddlewareService : DriverMiddlewareService
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
Internal
only for ext:lowlevel usage to retrieve configuration overview. *
Return values
arraygetConnectionNames()
Returns an array containing the names of all currently configured connections.
public
getConnectionNames() : array
This method should only be used in edge cases. Use getConnectionForTable() so that the tablename<>databaseConnection mapping will be taken into account.
Internal
Return values
arraygetOpenConnectionNames()
Returns the names of all connections that have already been instantiated in this pool. In contrast to getConnectionNames() this excludes configured but not yet used connections, so callers - for example the messenger worker middlewares pinging or closing connections - do not need to open connections just to act on them.
public
getOpenConnectionNames() : array<int, non-empty-string>
Internal
Return values
array<int, non-empty-string>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
static 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.
Internal
resetConnections()
Used to be used by functional tests to close statically stored connections, in order to use new connection in between single tests.
public
resetConnections() : void
This is a no-op nowadays since $this->connections
is no longer static and can be removed without replacement,
once testing framework is adapted to avoid calling this method.
getConnectionParams()
protected
getConnectionParams(string $connectionName) : array
Parameters
- $connectionName : string
Return values
arraygetDatabaseConnection()
Creates a connection object based on the specified parameters
protected
getDatabaseConnection(string $connectionName, array $connectionParams) : Connection
Parameters
- $connectionName : string
- $connectionParams : array
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 $connectionParams) : array
Parameters
- $connectionName : string
- $connectionParams : array
Return values
arraygetOrderedConnectionDriverMiddlewareConfiguration()
protected
getOrderedConnectionDriverMiddlewareConfiguration(string $connectionName, array $connectionParams) : array<non-empty-string, array{target: class-string, disabled: bool, after: string[], before: string[], type: string}>
Parameters
- $connectionName : string
- $connectionParams : array