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:
- Underlying-connection resolution in two modes: - layer mode — the
connectionparameter is the name (string) of another configuredDatabase; 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 theconnectionarray or from flat dsn/username/password parameters. 2. A worker-safe lifecycle skeleton (shutdown()nulls the handle; concrete adapters overrideping()/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.
Synopsis
Section titled “Synopsis”abstract class AbstractOrmDatabase extends Database
| Extends | Database |
| Source | Database/AbstractOrmDatabase.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
requireLibrary(string $probeClass, string $composerPackage): void | Assert that an ORM library is installed, with an actionable error message naming the composer package to install. |
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). |
resolveUnderlyingPdo(): PDO | Like AbstractOrmDatabase::resolveUnderlyingConnection() but requires the referenced connection to be a PDO instance (for ORMs that layer on a raw PDO). |
shutdown(): void | Execute the shutdown procedure. |
requireLibrary()
Section titled “requireLibrary()”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.
| Parameter | Type | Description |
|---|---|---|
$probeClass | string | |
$composerPackage | string |
resolveUnderlyingConnection()
Section titled “resolveUnderlyingConnection()”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
resolveUnderlyingPdo()
Section titled “resolveUnderlyingPdo()”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
shutdown()
Section titled “shutdown()”public function shutdown(): void
Execute the shutdown procedure.
| Throws | When |
|---|---|
DatabaseException | If an error occurs while shutting down this database. |
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. |
getPdo() | Database | Retrieve 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() | 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. |
ping() | Database | Probe whether the connection is still alive. |
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. |