‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Database\ConnectionPool Class Reference

Public Member Functions

 getConnectionForTable (string $tableName)
 
 getConnectionByName (string $connectionName)
 
 getQueryBuilderForTable (string $tableName)
 
 getConnectionNames ()
 
 registerDoctrineTypes ()
 
 resetConnections ()
 

Public Attributes

const DEFAULT_CONNECTION_NAME = 'Default'
 

Protected Member Functions

 mapCustomDriver (array $connectionParams)
 
 getDriverMiddlewares (array $connectionParams)
 
 getDatabaseConnection (array $connectionParams)
 

Protected Attributes

array $customDoctrineTypes
 
array $overrideDoctrineTypes
 

Static Protected Attributes

static Connection[] $connections = array( )
 
static string[] $driverMap
 

Detailed Description

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.

Definition at line 47 of file ConnectionPool.php.

Member Function Documentation

◆ getConnectionByName()

TYPO3\CMS\Core\Database\ConnectionPool::getConnectionByName ( string  $connectionName)

Creates a connection object based on the specified identifier.

This method should only be used in edge cases. Use getConnectionForTable() so that the tablename<>databaseConnection mapping will be taken into account.

Parameters
string$connectionName
Exceptions

Definition at line 120 of file ConnectionPool.php.

References $GLOBALS, and TYPO3\CMS\Core\Database\ConnectionPool\getDatabaseConnection().

Referenced by TYPO3\CMS\Core\Database\ConnectionPool\getConnectionForTable().

◆ getConnectionForTable()

TYPO3\CMS\Core\Database\ConnectionPool::getConnectionForTable ( string  $tableName)

Creates a connection object based on the specified table name.

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
string$tableName

Definition at line 94 of file ConnectionPool.php.

References $GLOBALS, TYPO3\CMS\Core\Database\ConnectionPool\DEFAULT_CONNECTION_NAME, and TYPO3\CMS\Core\Database\ConnectionPool\getConnectionByName().

Referenced by TYPO3\CMS\FrontendLogin\Domain\Repository\FrontendUserGroupRepository\__construct(), TYPO3\CMS\FrontendLogin\Domain\Repository\FrontendUserRepository\__construct(), TYPO3\CMS\Impexp\Domain\Repository\PresetRepository\__construct(), and TYPO3\CMS\Core\Database\ConnectionPool\getQueryBuilderForTable().

◆ getConnectionNames()

TYPO3\CMS\Core\Database\ConnectionPool::getConnectionNames ( )

Returns an array containing the names of all currently configured connections.

This method should only be used in edge cases. Use getConnectionForTable() so that the tablename<>databaseConnection mapping will be taken into account.

Definition at line 280 of file ConnectionPool.php.

References $GLOBALS.

◆ getDatabaseConnection()

TYPO3\CMS\Core\Database\ConnectionPool::getDatabaseConnection ( array  $connectionParams)
protected

◆ getDriverMiddlewares()

TYPO3\CMS\Core\Database\ConnectionPool::getDriverMiddlewares ( array  $connectionParams)
protected

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

Definition at line 190 of file ConnectionPool.php.

References $GLOBALS, and TYPO3\CMS\Webhooks\Message\$identifier.

Referenced by TYPO3\CMS\Core\Database\ConnectionPool\getDatabaseConnection().

◆ getQueryBuilderForTable()

TYPO3\CMS\Core\Database\ConnectionPool::getQueryBuilderForTable ( string  $tableName)

Returns the connection specific query builder object that can be used to build complex SQL queries using and object oriented approach.

Definition at line 260 of file ConnectionPool.php.

References TYPO3\CMS\Core\Database\ConnectionPool\getConnectionForTable().

Referenced by TYPO3\CMS\Impexp\Domain\Repository\PresetRepository\__construct().

◆ mapCustomDriver()

TYPO3\CMS\Core\Database\ConnectionPool::mapCustomDriver ( array  $connectionParams)
protected

Map custom driver class for certain driver

Definition at line 175 of file ConnectionPool.php.

Referenced by TYPO3\CMS\Core\Database\ConnectionPool\getDatabaseConnection().

◆ registerDoctrineTypes()

TYPO3\CMS\Core\Database\ConnectionPool::registerDoctrineTypes ( )

Register custom and override Doctrine data types implemented by TYPO3. 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.

Definition at line 293 of file ConnectionPool.php.

Referenced by TYPO3\CMS\Core\Database\ConnectionPool\getDatabaseConnection().

◆ resetConnections()

TYPO3\CMS\Core\Database\ConnectionPool::resetConnections ( )

Reset internal list of connections. Currently, primarily used in functional tests to close connections and start new ones in between single tests.

Definition at line 316 of file ConnectionPool.php.

Member Data Documentation

◆ $connections

Connection [] TYPO3\CMS\Core\Database\ConnectionPool::$connections = array( )
staticprotected

Definition at line 56 of file ConnectionPool.php.

◆ $customDoctrineTypes

array TYPO3\CMS\Core\Database\ConnectionPool::$customDoctrineTypes
protected
Initial value:
= [
‪EnumType::TYPE => EnumType::class,
‪SetType::TYPE => SetType::class,
]

Definition at line 61 of file ConnectionPool.php.

◆ $driverMap

string [] TYPO3\CMS\Core\Database\ConnectionPool::$driverMap
staticprotected
Initial value:
= array(
'pdo_mysql' => PDOMySqlDriver::class,
'pdo_sqlite' => PDOSqliteDriver::class,
'pdo_pgsql' => PDOPgSqlDriver::class,
)

List of custom drivers and their mappings to the driver classes.

Definition at line 80 of file ConnectionPool.php.

◆ $overrideDoctrineTypes

array TYPO3\CMS\Core\Database\ConnectionPool::$overrideDoctrineTypes
protected
Initial value:
= [
Types::DATE_MUTABLE => DateType::class,
Types::DATETIME_MUTABLE => DateTimeType::class,
Types::DATETIME_IMMUTABLE => DateTimeType::class,
Types::TIME_MUTABLE => TimeType::class,
]

Definition at line 69 of file ConnectionPool.php.

◆ DEFAULT_CONNECTION_NAME

const TYPO3\CMS\Core\Database\ConnectionPool::DEFAULT_CONNECTION_NAME = 'Default'

Definition at line 52 of file ConnectionPool.php.

Referenced by TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\addNewColumns(), TYPO3\CMS\Core\Database\Schema\ConnectionMigrator\buildSchemaDiff(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\changeExistingColumn(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\changeExistingIndex(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\changeTableEngine(), TYPO3\CMS\Install\Controller\InstallerController\checkDatabaseDataAction(), TYPO3\CMS\Install\Controller\InstallerController\checkDatabaseRequirementsAction(), TYPO3\CMS\Install\Service\SetupDatabaseService\checkDatabaseSelect(), TYPO3\CMS\Install\Service\SetupDatabaseService\checkExistingDatabase(), TYPO3\CMS\Install\Service\SetupDatabaseService\createDatabase(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\createNewTable(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\createNewTableIfNotExists(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\defaultNullWithoutNotNull(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\dropUnusedField(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\dropUnusedTable(), TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\enableFieldsStatementIsCorrect(), TYPO3\CMS\Core\Tests\Functional\Database\Query\Expression\ExpressionBuilderTest\ensureThatExpectedQuoteCharUsedInUnquoteIsValid(), TYPO3\CMS\Install\Database\PermissionsCheck\getConnection(), TYPO3\CMS\Core\Database\ConnectionPool\getConnectionForTable(), TYPO3\CMS\Core\Database\Schema\ConnectionMigrator\getConnectionNameForTable(), TYPO3\CMS\Install\Service\SetupDatabaseService\getDatabaseList(), TYPO3\CMS\Adminpanel\Modules\Debug\QueryInformation\getDataToStore(), TYPO3\CMS\Install\Service\SetupDatabaseService\getDefaultSocketFor(), TYPO3\CMS\Install\Service\SetupDatabaseService\getDriverOptions(), TYPO3\CMS\Reports\Report\Status\ConfigurationStatus\getMysqlDatabaseUtf8Status(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\getObjectDataByRawQuery(), TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableAdditionalFieldProvider\getOptimizableTables(), TYPO3\CMS\Install\Service\SetupDatabaseService\isDatabaseConfigurationComplete(), TYPO3\CMS\Install\Service\SetupDatabaseService\isDatabaseConnectSuccessful(), TYPO3\CMS\Reports\Report\Status\ConfigurationStatus\isMysqlUsed(), TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController\menuConfig(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\notNullWithoutDefaultValue(), TYPO3\CMS\Adminpanel\Middleware\SqlLogging\process(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\renameUnusedField(), and TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\renameUnusedTable().

‪TYPO3\CMS\Core\Database\Schema\Types\EnumType\TYPE
‪const TYPE
Definition: EnumType.php:30
‪TYPO3\CMS\Core\Database\Schema\Types\SetType\TYPE
‪const TYPE
Definition: SetType.php:30