Skip to content

PdoDatabase

PdoDatabase provides connectivity for the PDO database API layer.

class PdoDatabase extends Database

ExtendsDatabase
Since1.0.0
SourceDatabase/PdoDatabase.php
MethodDescription
getPdo(): PDORetrieve the underlying PDO connection.
initialize(DatabaseManager $databaseManager, array<string, mixed> $parameters = []): voidInitialize this Database.
ping(): boolProbe whether the PDO connection is still alive by running a lightweight query.
shutdown(): voidExecute the shutdown procedure.

public function getPdo(): PDO

Retrieve the underlying PDO connection.

Returns PDO

public function initialize(DatabaseManager $databaseManager, array<string, mixed> $parameters = []): void

Initialize this Database.

An assoc array of initialization params.

ParameterTypeDescription
$databaseManagerDatabaseManagerThe database manager of this instance.
$parametersarray``<``string``, ``mixed``>An assoc array of initialization params.

public function ping(): bool

Probe whether the PDO connection is still alive by running a lightweight query.

On failure (e.g. the MySQL server went away because the laptop slept while Docker was running) the stale connection is nulled so that the next call to getConnection() will reconnect transparently.

Returns bool

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.
getResource()DatabaseRetrieve a raw database resource associated with this Database implementation.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
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.