Connection
in package
Minimal, dependency-free PDO factory for schema introspection.
The scaffolding package does not depend on neuron-php/cms, so it cannot use
the CMS ConnectionFactory. This helper builds a read-only PDO connection
from a database settings array (adapter/host/port/name/user/pass, or a url).
Table of Contents
Methods
- adapter() : string
- Detect the adapter name for a PDO connection.
- fromConfig() : PDO
- Create a PDO connection from a database configuration array.
- parseUrl() : array<string|int, mixed>
- Parse a database URL into a configuration array.
Methods
adapter()
Detect the adapter name for a PDO connection.
public
static adapter(PDO $pdo) : string
Parameters
- $pdo : PDO
Return values
string —sqlite|mysql|pgsql
fromConfig()
Create a PDO connection from a database configuration array.
public
static fromConfig(array<string|int, mixed> $config) : PDO
Parameters
- $config : array<string|int, mixed>
Tags
Return values
PDOparseUrl()
Parse a database URL into a configuration array.
private
static parseUrl(string $url) : array<string|int, mixed>
Parameters
- $url : string