DriverManager
in package
Factory for creating {@link Connection} instances.
Tags
Table of Contents
- DRIVER_MAP = ['pdo_mysql' => \Doctrine\DBAL\Driver\PDO\MySQL\Driver::class, 'pdo_sqlite' => \Doctrine\DBAL\Driver\PDO\SQLite\Driver::class, 'pdo_pgsql' => \Doctrine\DBAL\Driver\PDO\PgSQL\Driver::class, 'pdo_oci' => \Doctrine\DBAL\Driver\PDO\OCI\Driver::class, 'oci8' => \Doctrine\DBAL\Driver\OCI8\Driver::class, 'ibm_db2' => \Doctrine\DBAL\Driver\IBMDB2\Driver::class, 'pdo_sqlsrv' => \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver::class, 'mysqli' => \Doctrine\DBAL\Driver\Mysqli\Driver::class, 'sqlsrv' => \Doctrine\DBAL\Driver\SQLSrv\Driver::class]
- List of supported drivers and their mappings to the driver classes.
- $driverSchemeAliases : array<string|int, string>
- List of URL schemes from a database URL and their mappings to driver.
- getAvailableDrivers() : array<string|int, string>
- Returns the list of supported drivers.
- getConnection() : Connection
- Creates a connection object based on the specified parameters.
- __construct() : mixed
- Private constructor. This class cannot be instantiated.
- createDriver() : Driver
- normalizeDatabaseUrlPath() : string
- Normalizes the given connection URL path.
- parseDatabaseUrl() : array<string|int, mixed>
- Extracts parts from a database URL, if present, and returns an updated list of parameters.
- parseDatabaseUrlPath() : array<string|int, mixed>
- Parses the given connection URL and resolves the given connection parameters.
- parseDatabaseUrlQuery() : array<string|int, mixed>
- Parses the query part of the given connection URL and resolves the given connection parameters.
- parseDatabaseUrlScheme() : array<string|int, mixed>
- Parses the scheme part from given connection URL and resolves the given connection parameters.
- parseRegularDatabaseUrlPath() : array<string|int, mixed>
- Parses the given regular connection URL and resolves the given connection parameters.
- parseSqliteDatabaseUrlPath() : array<string|int, mixed>
- Parses the given SQLite connection URL and resolves the given connection parameters.
Constants
DRIVER_MAP
List of supported drivers and their mappings to the driver classes.
private
mixed
DRIVER_MAP
= ['pdo_mysql' => \Doctrine\DBAL\Driver\PDO\MySQL\Driver::class, 'pdo_sqlite' => \Doctrine\DBAL\Driver\PDO\SQLite\Driver::class, 'pdo_pgsql' => \Doctrine\DBAL\Driver\PDO\PgSQL\Driver::class, 'pdo_oci' => \Doctrine\DBAL\Driver\PDO\OCI\Driver::class, 'oci8' => \Doctrine\DBAL\Driver\OCI8\Driver::class, 'ibm_db2' => \Doctrine\DBAL\Driver\IBMDB2\Driver::class, 'pdo_sqlsrv' => \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver::class, 'mysqli' => \Doctrine\DBAL\Driver\Mysqli\Driver::class, 'sqlsrv' => \Doctrine\DBAL\Driver\SQLSrv\Driver::class]
Properties
$driverSchemeAliases
List of URL schemes from a database URL and their mappings to driver.
private
static array<string|int, string>
$driverSchemeAliases
= [
'db2' => 'ibm_db2',
'mssql' => 'pdo_sqlsrv',
'mysql' => 'pdo_mysql',
'mysql2' => 'pdo_mysql',
// Amazon RDS, for some weird reason
'postgres' => 'pdo_pgsql',
'postgresql' => 'pdo_pgsql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
'sqlite3' => 'pdo_sqlite',
]
Methods
getAvailableDrivers()
Returns the list of supported drivers.
public
static getAvailableDrivers() : array<string|int, string>
Return values
array<string|int, string> —getConnection()
Creates a connection object based on the specified parameters.
public
static getConnection(array<string, mixed> $params[, Configuration|null $config = null ][, EventManager|null $eventManager = null ]) : Connection
This method returns a Doctrine\DBAL\Connection which wraps the underlying driver connection.
$params must contain at least one of the following.
Either 'driver' with one of the array keys of , OR 'driverClass' that contains the full class name (with namespace) of the driver class to instantiate.
Other (optional) parameters:
user (string): The username to use when connecting.
password (string): The password to use when connecting.
driverOptions (array): Any additional driver-specific options for the driver. These are just passed through to the driver.
wrapperClass: You may specify a custom wrapper class through the 'wrapperClass' parameter but this class MUST inherit from Doctrine\DBAL\Connection.
driverClass: The driver class to use.
Parameters
- $params : array<string, mixed>
- $config : Configuration|null = null
-
The configuration to use.
- $eventManager : EventManager|null = null
-
The event manager to use.
Tags
Return values
Connection —__construct()
Private constructor. This class cannot be instantiated.
private
__construct() : mixed
Tags
Return values
mixed —createDriver()
private
static createDriver(array<string, mixed> $params) : Driver
Parameters
- $params : array<string, mixed>
Tags
Return values
Driver —normalizeDatabaseUrlPath()
Normalizes the given connection URL path.
private
static normalizeDatabaseUrlPath(string $urlPath) : string
Parameters
- $urlPath : string
Return values
string —The normalized connection URL path
parseDatabaseUrl()
Extracts parts from a database URL, if present, and returns an updated list of parameters.
private
static parseDatabaseUrl(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
The list of parameters.
Tags
Return values
array<string|int, mixed> —A modified list of parameters with info from a database URL extracted into indidivual parameter parts.
parseDatabaseUrlPath()
Parses the given connection URL and resolves the given connection parameters.
private
static parseDatabaseUrlPath(array<string|int, mixed> $url, array<string|int, mixed> $params) : array<string|int, mixed>
Assumes that the connection URL scheme is already parsed and resolved into the given connection parameters via .
Parameters
- $url : array<string|int, mixed>
-
The URL parts to evaluate.
- $params : array<string|int, mixed>
-
The connection parameters to resolve.
Tags
Return values
array<string|int, mixed> —The resolved connection parameters.
parseDatabaseUrlQuery()
Parses the query part of the given connection URL and resolves the given connection parameters.
private
static parseDatabaseUrlQuery(array<string|int, mixed> $url, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $url : array<string|int, mixed>
-
The connection URL parts to evaluate.
- $params : array<string|int, mixed>
-
The connection parameters to resolve.
Return values
array<string|int, mixed> —The resolved connection parameters.
parseDatabaseUrlScheme()
Parses the scheme part from given connection URL and resolves the given connection parameters.
private
static parseDatabaseUrlScheme(string|null $scheme, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $scheme : string|null
-
The connection URL scheme, if available
- $params : array<string|int, mixed>
-
The connection parameters to resolve.
Tags
Return values
array<string|int, mixed> —The resolved connection parameters.
parseRegularDatabaseUrlPath()
Parses the given regular connection URL and resolves the given connection parameters.
private
static parseRegularDatabaseUrlPath(array<string|int, mixed> $url, array<string|int, mixed> $params) : array<string|int, mixed>
Assumes that the "path" URL part is already normalized via .
Parameters
- $url : array<string|int, mixed>
-
The regular connection URL parts to evaluate.
- $params : array<string|int, mixed>
-
The connection parameters to resolve.
Tags
Return values
array<string|int, mixed> —The resolved connection parameters.
parseSqliteDatabaseUrlPath()
Parses the given SQLite connection URL and resolves the given connection parameters.
private
static parseSqliteDatabaseUrlPath(array<string|int, mixed> $url, array<string|int, mixed> $params) : array<string|int, mixed>
Assumes that the "path" URL part is already normalized via .
Parameters
- $url : array<string|int, mixed>
-
The SQLite connection URL parts to evaluate.
- $params : array<string|int, mixed>
-
The connection parameters to resolve.
Tags
Return values
array<string|int, mixed> —The resolved connection parameters.