Documentation

DriverManager
in package

Factory for creating Doctrine\DBAL\Connection instances.

Tags
author

Roman Borschel roman@code-factory.org

since
2.0

Table of Contents

$_driverMap  : array<string|int, mixed>
List of supported drivers and their mappings to the driver classes.
$driverSchemeAliases  : mixed
List of URL schemes from a database URL and their mappings to driver.
getAvailableDrivers()  : array<string|int, mixed>
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.
_checkParams()  : void
Checks the list of parameters.
normalizeDatabaseUrlPath()  : string
Normalizes the given connection URL path.
parseDatabaseUrl()  : 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.

Properties

$_driverMap

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

private static array<string|int, mixed> $_driverMap = array('pdo_mysql' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', 'pdo_sqlite' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver', 'pdo_pgsql' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver', 'pdo_oci' => 'Doctrine\DBAL\Driver\PDOOracle\Driver', 'oci8' => 'Doctrine\DBAL\Driver\OCI8\Driver', 'ibm_db2' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver', 'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver', 'mysqli' => 'Doctrine\DBAL\Driver\Mysqli\Driver', 'drizzle_pdo_mysql' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver', 'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver', 'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver')

To add your own driver use the 'driverClass' parameter to .

$driverSchemeAliases

List of URL schemes from a database URL and their mappings to driver.

private static mixed $driverSchemeAliases = array( '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, mixed>
Return values
array<string|int, mixed>

getConnection()

Creates a connection object based on the specified parameters.

public static getConnection(array<string|int, 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 following values:

pdo_mysql
pdo_sqlite
pdo_pgsql
pdo_oci (unstable)
pdo_sqlsrv
pdo_sqlsrv
mysqli
sqlanywhere
sqlsrv
ibm_db2 (unstable)
drizzle_pdo_mysql

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.

pdo: You can pass an existing PDO instance through this parameter. The PDO instance will be wrapped in a Doctrine\DBAL\Connection.

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|int, mixed>

The parameters.

$config : Configuration|null = null

The configuration to use.

$eventManager : EventManager|null = null

The event manager to use.

Tags
throws
DBALException
Return values
Connection

__construct()

Private constructor. This class cannot be instantiated.

private __construct() : mixed
Return values
mixed

_checkParams()

Checks the list of parameters.

private static _checkParams(array<string|int, mixed> $params) : void
Parameters
$params : array<string|int, mixed>

The list of parameters.

Tags
throws
DBALException
Return values
void

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) : mixed
Parameters
$params : array<string|int, mixed>

The list of parameters.

Return values
mixed

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
see
parseDatabaseUrlScheme
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(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.

Tags
throws
DBALException

if parsing failed or resolution is not possible.

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
see
normalizeDatabaseUrlPath
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
see
normalizeDatabaseUrlPath
Return values
array<string|int, mixed>

The resolved connection parameters.

Search results