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.
Table of Contents
Constants
- DEFAULT_CONNECTION_NAME : string = 'Default'
Properties
- $connections : Connection[]
- $customDoctrineTypes : array<non-empty-string, class-string>
- $driverMap : string[]
- List of custom drivers and their mappings to the driver classes.
- $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.
- getConnectionNames() : array
- 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.
- 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: $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['driverMiddlewares']
- mapCustomDriver() : array
- Map custom driver class for certain driver
Constants
DEFAULT_CONNECTION_NAME
public
string
DEFAULT_CONNECTION_NAME
= 'Default'
Properties
$connections
protected
static Connection[]
$connections
= []
$customDoctrineTypes
protected
array<non-empty-string, class-string>
$customDoctrineTypes
= [\TYPO3\CMS\Core\Database\Schema\Types\EnumType::TYPE => \TY…Show the full value
[\TYPO3\CMS\Core\Database\Schema\Types\EnumType::TYPE => \TYPO3\CMS\Core\Database\Schema\Types\EnumType::class, \TYPO3\CMS\Core\Database\Schema\Types\SetType::TYPE => \TYPO3\CMS\Core\Database\Schema\Types\SetType::class]
$driverMap
List of custom drivers and their mappings to the driver classes.
protected
static string[]
$driverMap
= ['pdo_mysql' => \TYPO3\CMS\Core\Database\Driver\PDOMySql\Dri…Show the full value
['pdo_mysql' => \TYPO3\CMS\Core\Database\Driver\PDOMySql\Driver::class, 'pdo_sqlite' => \TYPO3\CMS\Core\Database\Driver\PDOSqlite\Driver::class, 'pdo_pgsql' => \TYPO3\CMS\Core\Database\Driver\PDOPgSql\Driver::class]
$overrideDoctrineTypes
protected
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]
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
ConnectiongetConnectionNames()
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
arraygetQueryBuilderForTable()
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.
Internal
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.
getDatabaseConnection()
Creates a connection object based on the specified parameters
protected
getDatabaseConnection(array $connectionParams) : Connection
Parameters
- $connectionParams : array
Return values
ConnectiongetDriverMiddlewares()
Return any doctrine driver middlewares, that may have been set up in: $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['driverMiddlewares']
protected
getDriverMiddlewares(array $connectionParams) : array
Parameters
- $connectionParams : array
Return values
arraymapCustomDriver()
Map custom driver class for certain driver
protected
mapCustomDriver(array $connectionParams) : array
Parameters
- $connectionParams : array
Internal