PdoDatabase
PdoDatabase provides connectivity for the PDO database API layer.
Synopsis
Section titled “Synopsis”class PdoDatabase extends Database
| Extends | Database |
| Since | 1.0.0 |
| Source | Database/PdoDatabase.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getPdo(): PDO | Retrieve the underlying PDO connection. |
initialize(DatabaseManager $databaseManager, array<string, mixed> $parameters = []): void | Initialize this Database. |
ping(): bool | Probe whether the PDO connection is still alive by running a lightweight query. |
shutdown(): void | Execute the shutdown procedure. |
getPdo()
Section titled “getPdo()”public function getPdo(): PDO
Retrieve the underlying PDO connection.
Returns PDO
initialize()
Section titled “initialize()”public function initialize(DatabaseManager $databaseManager, array<string, mixed> $parameters = []): void
Initialize this Database.
An assoc array of initialization params.
| Parameter | Type | Description |
|---|---|---|
$databaseManager | DatabaseManager | The database manager of this instance. |
$parameters | array``<``string``, ``mixed``> | An assoc array of initialization params. |
ping()
Section titled “ping()”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
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. |
getResource() | Database | Retrieve a raw database resource associated with this Database implementation. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
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. |