final class DatabaseConfig (View source)

Carries normalized connection settings independently of configuration source format.

Methods

__construct(Driver $driver, string $host, int $port, string $database, string $username, string $password, string $charset, string $collation = '', string $prefix = '', bool $strict = true, bool $persistent = false, DatabaseDialect|null $dialect = null, string|null $dsn = null, array $options = [])

Captures all connection options after their caller-selected defaults have been applied.

fromArray(array $config)

Normalizes an untrusted connection mapping into a validated immutable configuration.

Driver
driver()

Returns the selected connection driver family.

Driver
string
host()

Returns the configured network host for network-capable drivers.

string
int
port()

Returns the configured network port for network-capable drivers.

int
string

Returns the selected database or catalog name.

string
string

Returns the configured database login name.

string
string

Returns the configured database login secret.

string
string

Returns the connection character set requested from the driver.

string
string

Returns the optional collation requested after connection setup.

string
string
prefix()

Returns the table-name prefix applied by driver-level identifier protection.

string
bool
strict()

Indicates whether the connection should request strict SQL behavior where supported.

bool
bool

Indicates whether the driver may reuse a persistent physical connection.

bool
DatabaseDialect|null

Returns an explicitly configured dialect or the dialect implied by a concrete driver.

DatabaseDialect|null
string|null
dsn()

Returns an explicit DSN when it overrides host-based DSN construction.

string|null
array

Returns driver-specific connection options retained without framework interpretation.

array

Details

__construct

__construct(Driver $driver, string $host, int $port, string $database, string $username, string $password, string $charset, string $collation = '', string $prefix = '', bool $strict = true, bool $persistent = false, DatabaseDialect|null $dialect = null, string|null $dsn = null, array $options = [])

Captures all connection options after their caller-selected defaults have been applied.

Parameters

Driver $driver
string $host
int $port
string $database
string $username
string $password
string $charset
string $collation
string $prefix
bool $strict
bool $persistent
DatabaseDialect|null $dialect
string|null $dsn
array $options

fromArray

static DatabaseConfig fromArray(array $config)

Normalizes an untrusted connection mapping into a validated immutable configuration.

Parameters

array $config

Return Value

DatabaseConfig

Exceptions

DatabaseException

driver

Driver driver()

Returns the selected connection driver family.

Return Value

Driver

host

string host()

Returns the configured network host for network-capable drivers.

Return Value

string

port

int port()

Returns the configured network port for network-capable drivers.

Return Value

int

database

string database()

Returns the selected database or catalog name.

Return Value

string

username

string username()

Returns the configured database login name.

Return Value

string

password

string password()

Returns the configured database login secret.

Return Value

string

charset

string charset()

Returns the connection character set requested from the driver.

Return Value

string

collation

string collation()

Returns the optional collation requested after connection setup.

Return Value

string

prefix

string prefix()

Returns the table-name prefix applied by driver-level identifier protection.

Return Value

string

strict

bool strict()

Indicates whether the connection should request strict SQL behavior where supported.

Return Value

bool

persistent

bool persistent()

Indicates whether the driver may reuse a persistent physical connection.

Return Value

bool

dialect

DatabaseDialect|null dialect()

Returns an explicitly configured dialect or the dialect implied by a concrete driver.

Return Value

DatabaseDialect|null

dsn

string|null dsn()

Returns an explicit DSN when it overrides host-based DSN construction.

Return Value

string|null

options

array options()

Returns driver-specific connection options retained without framework interpretation.

Return Value

array