class ConnectionFactory (View source)

Properties

protected Container $container The IoC container instance.

Methods

void
__construct(Container $container)

Create a new connection factory instance.

make(array $config, string $name = null)

Establish a PDO connection based on the configuration.

createSingleConnection(array $config)

Create a single database connection instance.

createReadWriteConnection(array $config)

Create a single database connection instance.

PDO
createReadPdo(array $config)

Create a new PDO instance for reading.

array
getReadConfig(array $config)

Get the read configuration for a read / write connection.

array
getWriteConfig(array $config)

Get the read configuration for a read / write connection.

array
getReadWriteConfig(array $config, string $type)

Get a read / write level configuration.

array
mergeReadWriteConfig(array $config, array $merge)

Merge a configuration for a read / write connection.

array
parseConfig(array $config, string $name)

Parse and prepare the database configuration.

createConnector(array $config)

Create a connector instance based on the configuration.

createConnection(string $driver, PDO $connection, string $database, string $prefix = '', array $config = [])

Create a new connection instance.

Details

void __construct(Container $container)

Create a new connection factory instance.

Parameters

Container $container

Return Value

void

Connection make(array $config, string $name = null)

Establish a PDO connection based on the configuration.

Parameters

array $config
string $name

Return Value

Connection

protected Connection createSingleConnection(array $config)

Create a single database connection instance.

Parameters

array $config

Return Value

Connection

protected Connection createReadWriteConnection(array $config)

Create a single database connection instance.

Parameters

array $config

Return Value

Connection

protected PDO createReadPdo(array $config)

Create a new PDO instance for reading.

Parameters

array $config

Return Value

PDO

protected array getReadConfig(array $config)

Get the read configuration for a read / write connection.

Parameters

array $config

Return Value

array

protected array getWriteConfig(array $config)

Get the read configuration for a read / write connection.

Parameters

array $config

Return Value

array

protected array getReadWriteConfig(array $config, string $type)

Get a read / write level configuration.

Parameters

array $config
string $type

Return Value

array

protected array mergeReadWriteConfig(array $config, array $merge)

Merge a configuration for a read / write connection.

Parameters

array $config
array $merge

Return Value

array

protected array parseConfig(array $config, string $name)

Parse and prepare the database configuration.

Parameters

array $config
string $name

Return Value

array

ConnectorInterface createConnector(array $config)

Create a connector instance based on the configuration.

Parameters

array $config

Return Value

ConnectorInterface

Exceptions

InvalidArgumentException

protected Connection createConnection(string $driver, PDO $connection, string $database, string $prefix = '', array $config = [])

Create a new connection instance.

Parameters

string $driver
PDO $connection
string $database
string $prefix
array $config

Return Value

Connection

Exceptions

InvalidArgumentException