Neuron-PHP

Connection

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
throws
Exception

if the adapter is unsupported or configuration is invalid

Return values
PDO

parseUrl()

Parse a database URL into a configuration array.

private static parseUrl(string $url) : array<string|int, mixed>
Parameters
$url : string
Tags
throws
Exception

if the URL is malformed

Return values
array<string|int, mixed>
On this page

Search results