DoctrineDbalDatabase
Tier-2 adapter: a Doctrine DBAL connection (connection abstraction + query builder) without the ORM/entity layer.
DoctrineDbalDatabase::getConnection() returns the Connection.
Parameters: either an inline connection array, a DSN url, or flat driver/host/dbname/user/password params (see DoctrineDbalParams).
Synopsis
Section titled “Synopsis”class DoctrineDbalDatabase extends AbstractOrmDatabase
| Extends | AbstractOrmDatabase |
| Uses | DoctrineDbalParams |
| Source | DoctrineDbalDatabase.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getDbalConnection(): Connection | Returns the DBAL connection, connecting on first use. |
getPdo(): PDO | Only available when the configured driver is a pdo_* one (pdo_mysql, pdo_pgsql, pdo_sqlite, …) — DBAL 4 also supports native drivers (mysqli, pgsql) that never construct a \PDO instance at all. |
getQueryBuilder(): QueryBuilder | Returns a fresh DBAL query builder bound to this connection. |
ping(): bool | Probes the connection with SELECT 1. |
shutdown(): mixed | Rolls back any open transaction, closes the connection and drops it. |
getDbalConnection()
Section titled “getDbalConnection()”public function getDbalConnection(): Connection
Returns the DBAL connection, connecting on first use.
Returns Connection
| Throws | When |
|---|---|
DatabaseException | If the connection could not be created, or what was created is not a DBAL Connection. |
getPdo()
Section titled “getPdo()”public function getPdo(): PDO
Only available when the configured driver is a pdo_* one (pdo_mysql, pdo_pgsql, pdo_sqlite, …) — DBAL 4 also supports native drivers (mysqli, pgsql) that never construct a \PDO instance at all.
Returns PDO
getQueryBuilder()
Section titled “getQueryBuilder()”public function getQueryBuilder(): QueryBuilder
Returns a fresh DBAL query builder bound to this connection.
A new builder is created on every call, so callers never share state.
Returns QueryBuilder
| Throws | When |
|---|---|
DatabaseException | If the connection could not be created. |
ping()
Section titled “ping()”public function ping(): bool
Probes the connection with SELECT 1.
Returns true when nothing has been connected yet, since lazy connect handles it on first use. If the query throws, the connection and resource are cleared so the next getConnection() reconnects, and false is returned.
Returns bool
shutdown()
Section titled “shutdown()”public function shutdown(): mixed
Rolls back any open transaction, closes the connection and drops it.
A failure to roll back or close is logged at warning and does not stop the shutdown; the connection and resource are cleared either way.
Returns mixed
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
appendParameter() | ParameterHolder | Append a parameter. |
appendParameterByRef() | ParameterHolder | Append a parameter by reference. |
clearParameters() | ParameterHolder | Clear all parameters associated with this request. |
getConnection() | Database | Retrieve the database connection associated with this Database implementation. |
getDatabaseManager() | Database | Retrieve the Database Manager instance for this implementation. |
getFlatParameterNames() | ParameterHolder | Retrieve an array of flattened parameter names. |
getName() | Database | Retrieve the name of this database connection. |
getParameter() | ParameterHolder | Retrieve a parameter. |
getParameterNames() | ParameterHolder | Retrieve an array of parameter names. |
getParameters() | ParameterHolder | Retrieve an array of parameters. |
getResource() | Database | Retrieve a raw database resource associated with this Database implementation. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
initialize() | Database | Initialize this Database. |
removeParameter() | ParameterHolder | Remove a parameter. |
reset() | Database | Returns this Database to its pre-initialize() state. |
setParameter() | ParameterHolder | Set a parameter. |
setParameterByRef() | ParameterHolder | Set a parameter by reference. |
setParameters() | ParameterHolder | Set an array of parameters. |
setParametersByRef() | ParameterHolder | Set an array of parameters by reference. |
startup() | Database | Do any necessary startup work after initialization. |