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

Public Member Functions

Connection getConnectionForTable (string $tableName)
 
Connection getConnectionByName (string $connectionName)
 
QueryBuilder getQueryBuilderForTable (string $tableName)
 
array getConnectionNames ()
 
array getCustomDoctrineTypes ()
 
 resetConnections ()
 

Public Attributes

const DEFAULT_CONNECTION_NAME = 'Default'
 

Protected Member Functions

array mapCustomDriver (array $connectionParams)
 
Connection getDatabaseConnection (array $connectionParams)
 

Protected Attributes

array $customDoctrineTypes
 

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 45 of file ConnectionPool.php.

Member Function Documentation

◆ getConnectionByName()

Connection 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
Returns
Connection
Exceptions

Definition at line 113 of file ConnectionPool.php.

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

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

◆ getConnectionForTable()

Connection 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
Returns
Connection

Definition at line 86 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\Core\Database\ConnectionPool\getQueryBuilderForTable().

◆ getConnectionNames()

array 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.

Returns
‪array

Definition at line 250 of file ConnectionPool.php.

References $GLOBALS.

◆ getCustomDoctrineTypes()

array TYPO3\CMS\Core\Database\ConnectionPool::getCustomDoctrineTypes ( )

Returns the list of custom Doctrine data types implemented by TYPO3. This method is needed by the Schema parser to register the types as it does not require a database connection and thus the types don't get registered automatically.

Returns
‪array

Definition at line 264 of file ConnectionPool.php.

References TYPO3\CMS\Core\Database\ConnectionPool\$customDoctrineTypes.

◆ getDatabaseConnection()

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

Creates a connection object based on the specified parameters

Parameters
array$connectionParams
Returns
Connection

Definition at line 173 of file ConnectionPool.php.

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

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

◆ getQueryBuilderForTable()

QueryBuilder 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.

Parameters
string$tableName
Returns
‪QueryBuilder

Definition at line 229 of file ConnectionPool.php.

References TYPO3\CMS\Core\Database\Connection\createQueryBuilder(), and TYPO3\CMS\Core\Database\ConnectionPool\getConnectionForTable().

◆ mapCustomDriver()

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

Map custom driver class for certain driver

Parameters
array$connectionParams
Returns
‪array

Definition at line 157 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 274 of file ConnectionPool.php.

Member Data Documentation

◆ $connections

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

Definition at line 54 of file ConnectionPool.php.

◆ $customDoctrineTypes

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

Definition at line 58 of file ConnectionPool.php.

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

◆ $driverMap

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

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

Definition at line 67 of file ConnectionPool.php.

◆ DEFAULT_CONNECTION_NAME

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

Definition at line 50 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\Controller\InstallerController\checkDatabaseSelectAction(), TYPO3\CMS\Install\Controller\InstallerController\checkExistingDatabase(), TYPO3\CMS\Install\Controller\InstallerController\createNewDatabase(), 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\Install\Database\PermissionsCheck\getConnection(), TYPO3\CMS\Core\Database\ConnectionPool\getConnectionForTable(), TYPO3\CMS\Core\Database\Schema\ConnectionMigrator\getConnectionNameForTable(), TYPO3\CMS\Install\Controller\InstallerController\getDatabaseList(), TYPO3\CMS\Adminpanel\Modules\Debug\QueryInformation\getDataToStore(), TYPO3\CMS\Install\Controller\InstallerController\getDefaultSocketFor(), 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\UpgradeWizardsService\isDatabaseCharsetUtf8(), TYPO3\CMS\Install\Controller\InstallerController\isDatabaseConfigurationComplete(), TYPO3\CMS\Install\Controller\InstallerController\isDatabaseConnectSuccessful(), TYPO3\CMS\Reports\Report\Status\ConfigurationStatus\isMysqlUsed(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\notNullWithoutDefaultValue(), TYPO3\CMS\Adminpanel\Middleware\SqlLogging\process(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\renameUnusedField(), TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest\renameUnusedTable(), TYPO3\CMS\Install\Service\UpgradeWizardsService\setDatabaseCharsetUtf8(), TYPO3\CMS\Install\Controller\InstallerController\showDatabaseConnectAction(), and TYPO3\CMS\Core\Database\ReferenceIndex\updateIndex().

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