Skip to content

AbstractOrmDatabase

Shared base for ORM adapters whose AbstractOrmDatabase::getConnection() returns an ORM manager (Eloquent Capsule, Doctrine EntityManager, Cycle ORM) rather than a raw PDO handle.

It pulls up the two things every such adapter needs:

  1. Underlying-connection resolution in two modes: - layer mode — the connection parameter is the name (string) of another configured Database; the ORM reuses that connection (credentials live in one place, PDO-level ping/reconnect is reused). - standalone mode — the ORM builds its own connection from the connection array or from flat dsn/username/password parameters. 2. A worker-safe lifecycle skeleton (shutdown() nulls the handle; concrete adapters override ping()/reset() to clear per-request ORM state).

Concrete adapters remain thin: they only translate resolved connection info into their ORM’s bootstrap and expose typed accessors.

abstract class AbstractOrmDatabase extends Database

ExtendsDatabase
SourceDatabase/AbstractOrmDatabase.php
MethodDescription
requireLibrary(string $probeClass, string $composerPackage): voidAssert that an ORM library is installed, with an actionable error message naming the composer package to install.
resolveUnderlyingConnection(): mixedResolve the connection parameter to an underlying object: - string → the name of another configured Database; returns its getConnection() (typically a PDO or a DBAL Connection).
resolveUnderlyingPdo(): PDOLike AbstractOrmDatabase::resolveUnderlyingConnection() but requires the referenced connection to be a PDO instance (for ORMs that layer on a raw PDO).
shutdown(): voidExecute the shutdown procedure.

protected function requireLibrary(string $probeClass, string $composerPackage): void

Assert that an ORM library is installed, with an actionable error message naming the composer package to install.

ParameterTypeDescription
$probeClassstring
$composerPackagestring

protected function resolveUnderlyingConnection(): mixed

Resolve the connection parameter to an underlying object: - string → the name of another configured Database; returns its getConnection() (typically a PDO or a DBAL Connection).

  • array → returned as-is (inline connection details for the ORM). - null → null (adapter should build its own from flat params).

Returns mixed

protected function resolveUnderlyingPdo(): PDO

Like AbstractOrmDatabase::resolveUnderlyingConnection() but requires the referenced connection to be a PDO instance (for ORMs that layer on a raw PDO).

Returns PDO

public function shutdown(): void

Execute the shutdown procedure.

ThrowsWhen
DatabaseExceptionIf an error occurs while shutting down this database.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearParameters()ParameterHolderClear all parameters associated with this request.
getConnection()DatabaseRetrieve the database connection associated with this Database implementation.
getDatabaseManager()DatabaseRetrieve the Database Manager instance for this implementation.
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getName()DatabaseRetrieve the name of this database connection.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
getPdo()DatabaseRetrieve the raw PDO connection underlying this database, for callers that need to hand-write SQL (custom queries, driver-specific optimizations) rather than go through an ORM’s query builder.
getResource()DatabaseRetrieve a raw database resource associated with this Database implementation.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
initialize()DatabaseInitialize this Database.
ping()DatabaseProbe whether the connection is still alive.
removeParameter()ParameterHolderRemove a parameter.
reset()DatabaseReturns this Database to its pre-initialize() state.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.
startup()DatabaseDo any necessary startup work after initialization.