PropulsionDatabase
First-class adapter for Propulsion (the quioteframework/propulsion fork of Propel 1).
The adapter bootstraps Propulsion from its runtime config and returns a datasource PDO connection from PropulsionDatabase::getConnection().
Configuration parameters (in databases.xml): - config : path to the Propulsion runtime config file - datasource : datasource to use (default = config default) - overrides : key/value overrides applied after init - init_queries : extra connection init queries to append - enable_instance_pooling : true/false to force pooling behavior
Synopsis
Section titled “Synopsis”class PropulsionDatabase extends Database
| Extends | Database |
| Source | PropulsionDatabase.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getConfigPath(): string | Returns the config parameter as configured. |
getConnection(): mixed | Resolves the connection from Propulsion on every call instead of trusting the base class’s connect-once cache. |
getDatasource(): string | Returns the Propulsion datasource this database connects through. |
getPdo(): PDO | Returns the datasource connection as a plain PDO handle. |
getPropulsionConnection(): PropulsionPDO | Returns the connection narrowed to Propulsion’s own PDO subclass. |
getResource(): mixed | Retrieve a raw database resource associated with this Database implementation. |
initialize(DatabaseManager $databaseManager, array<string, mixed> $parameters = []): void | Initialize this Database. |
ping(): bool | Probes the connection with SELECT 1. |
reset(): void | Returns this database to its pre-initialize() state, dropping Propulsion’s request-scoped session first. |
shutdown(): mixed | Closes Propulsion and drops the connection. |
getConfigPath()
Section titled “getConfigPath()”public function getConfigPath(): string
Returns the config parameter as configured.
This is the raw parameter value, not the directive-expanded path that initialize() actually loaded.
Returns string
| Throws | When |
|---|---|
DatabaseException | If the config parameter is absent or not a non-empty string. |
getConnection()
Section titled “getConnection()”public function getConnection(): mixed
Resolves the connection from Propulsion on every call instead of trusting the base class’s connect-once cache.
Propulsion::initialize() can drop its pooled connections underneath this adapter (see PropulsionDatabase::initialize()’s reconfiguration branch), which empties Propulsion’s own connection map without touching $this->connection. If that cached handle were returned here, this adapter and the ORM acting through Propulsion would silently operate on two different backends — e.g. a lock taken through this handle would never be visible to a write Propulsion itself performs. Propulsion::getConnection() is a pooled map lookup, so re-resolving on every call costs nothing and can never go stale.
Returns mixed
| Throws | When |
|---|---|
DatabaseException | If a connection could not be created. |
getDatasource()
Section titled “getDatasource()”public function getDatasource(): string
Returns the Propulsion datasource this database connects through.
Resolved during initialize() from the datasource parameter or from the config file’s default datasource; default until then.
Returns string
getPdo()
Section titled “getPdo()”public function getPdo(): PDO
Returns the datasource connection as a plain PDO handle.
PropulsionPDO is an interface, and each concrete implementation extends the driver-specific PDO subclass rather than PDO itself, so the PDO instance is checked for here instead of being taken on trust.
Returns PDO
| Throws | When |
|---|---|
DatabaseException | If the connection could not be created, is not a PropulsionPDO, or is a PropulsionPDO that does not extend PDO. |
getPropulsionConnection()
Section titled “getPropulsionConnection()”public function getPropulsionConnection(): PropulsionPDO
Returns the connection narrowed to Propulsion’s own PDO subclass.
Connects lazily on first call. Use this over getConnection() when the caller needs Propulsion-specific PDO behaviour.
Returns PropulsionPDO
| Throws | When |
|---|---|
DatabaseException | If a connection could not be created, or the datasource handed back something that is not a PropulsionPDO. |
getResource()
Section titled “getResource()”public function getResource(): mixed
Retrieve a raw database resource associated with this Database implementation.
Returns mixed — A database resource.
| Throws | When |
|---|---|
DatabaseException | If a connection could not be created. |
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. |
| Throws | When |
|---|---|
InitializationException | If an error occurs while initializing this Database. |
ping()
Section titled “ping()”public function ping(): bool
Probes the connection with SELECT 1.
Returns true when no connection has been opened yet, since lazy connect will create a fresh one on first use. On any failure — including the connection not being a PDO instance — the connection and resource are cleared so the next getConnection() reconnects, and false is returned.
Returns bool
reset()
Section titled “reset()”public function reset(): void
Returns this database to its pre-initialize() state, dropping Propulsion’s request-scoped session first.
That session (instance pool, unit-of-work state) lives on Propulsion itself rather than on this object, so the base teardown — which shuts the connection down and clears the parameters, the manager reference and the name — would leave it behind. Re-initialize() this instance before using it again.
| Throws | When |
|---|---|
DatabaseException | If shutting the connection down fails. |
shutdown()
Section titled “shutdown()”public function shutdown(): mixed
Closes Propulsion and drops the connection.
Propulsion::close() is only called when Propulsion was initialized; the connection and resource are cleared either way, so a later getConnection() opens a new one.
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. |
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. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
removeParameter() | ParameterHolder | Remove a parameter. |
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. |