W3cubDocs

/Laravel 8

ConnectionFactory

class ConnectionFactory (View source)

Properties

protected Container $container The IoC container instance.

Methods

void __construct(Container $container)

Create a new connection factory instance.

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

Establish a PDO connection based on the configuration.

array parseConfig(array $config, string $name)

Parse and prepare the database configuration.

Connection createSingleConnection(array $config)

Create a single database connection instance.

Connection createReadWriteConnection(array $config)

Create a read / write database connection instance.

Closure 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 write 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.

Closure createPdoResolver(array $config)

Create a new Closure that resolves to a PDO instance.

Closure createPdoResolverWithHosts(array $config)

Create a new Closure that resolves to a PDO instance with a specific host or an array of hosts.

array parseHosts(array $config)

Parse the hosts configuration item into an array.

Closure createPdoResolverWithoutHosts(array $config)

Create a new Closure that resolves to a PDO instance where there is no configured host.

ConnectorInterface createConnector(array $config)

Create a connector instance based on the configuration.

Connection createConnection(string $driver, PDO|Closure $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|null $name = null)

Establish a PDO connection based on the configuration.

Parameters

array $config
string|null $name

Return Value

Connection

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

Parse and prepare the database configuration.

Parameters

array $config
string $name

Return Value

array

protected Connection createSingleConnection(array $config)

Create a single database connection instance.

Parameters

array $config

Return Value

Connection

protected Connection createReadWriteConnection(array $config)

Create a read / write database connection instance.

Parameters

array $config

Return Value

Connection

protected Closure createReadPdo(array $config)

Create a new PDO instance for reading.

Parameters

array $config

Return Value

Closure

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 write 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 Closure createPdoResolver(array $config)

Create a new Closure that resolves to a PDO instance.

Parameters

array $config

Return Value

Closure

protected Closure createPdoResolverWithHosts(array $config)

Create a new Closure that resolves to a PDO instance with a specific host or an array of hosts.

Parameters

array $config

Return Value

Closure

Exceptions

PDOException

protected array parseHosts(array $config)

Parse the hosts configuration item into an array.

Parameters

array $config

Return Value

array

Exceptions

InvalidArgumentException

protected Closure createPdoResolverWithoutHosts(array $config)

Create a new Closure that resolves to a PDO instance where there is no configured host.

Parameters

array $config

Return Value

Closure

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|Closure $connection, string $database, string $prefix = '', array $config = [])

Create a new connection instance.

Parameters

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

Return Value

Connection

Exceptions

InvalidArgumentException

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Database/Connectors/ConnectionFactory.html