laravel / 8 / api / 8.x / illuminate / database / databasemanager.html

DatabaseManager

class DatabaseManager implements ConnectionResolverInterface mixin Connection (View source)

Properties

protected Application $app

The application instance.

protected ConnectionFactory $factory

The database connection factory instance.

protected array $connections

The active connection instances.

protected array $extensions

The custom connection resolvers.

protected callable $reconnector

The callback to be executed to reconnect to a database.

protected array $doctrineTypes

The custom Doctrine column types.

Methods

void __construct(Application $app, ConnectionFactory $factory)

Create a new database manager instance.

ConnectionInterface connection(string|null $name = null)

Get a database connection instance.

array parseConnectionName(string $name)

Parse the connection into an array of the name and read / write type.

Connection makeConnection(string $name)

Make the database connection instance.

array configuration(string $name)

Get the configuration for a connection.

Connection configure(Connection $connection, string $type)

Prepare the database connection instance.

Connection setPdoForType(Connection $connection, string|null $type = null)

Prepare the read / write mode for database connection instance.

void registerConfiguredDoctrineTypes(Connection $connection)

Register custom Doctrine types with the connection.

void registerDoctrineType(string $class, string $name, string $type)

Register a custom Doctrine type.

void purge(string|null $name = null)

Disconnect from the given database and remove from local cache.

void disconnect(string|null $name = null)

Disconnect from the given database.

Connection reconnect(string|null $name = null)

Reconnect to the given database.

mixed usingConnection(string $name, callable $callback)

Set the default database connection for the callback execution.

Connection refreshPdoConnections(string $name)

Refresh the PDO connections on a given connection.

string getDefaultConnection()

Get the default connection name.

void setDefaultConnection(string $name)

Set the default connection name.

array supportedDrivers()

Get all of the support drivers.

array availableDrivers()

Get all of the drivers that are actually available.

void extend(string $name, callable $resolver)

Register an extension connection resolver.

array getConnections()

Return all of the created connections.

void setReconnector(callable $reconnector)

Set the database reconnector callback.

$this setApplication(Application $app)

Set the application instance used by the manager.

mixed __call(string $method, array $parameters)

Dynamically pass methods to the default connection.

Details

void __construct(Application $app, ConnectionFactory $factory)

Create a new database manager instance.

Parameters

Return Value

void

ConnectionInterface connection(string|null $name = null)

Get a database connection instance.

Parameters

string|null $name

Return Value

protected array parseConnectionName(string $name)

Parse the connection into an array of the name and read / write type.

Parameters

string $name

Return Value

array

protected Connection makeConnection(string $name)

Make the database connection instance.

Parameters

string $name

Return Value

protected array configuration(string $name)

Get the configuration for a connection.

Parameters

string $name

Return Value

array

Exceptions

protected Connection configure(Connection $connection, string $type)

Prepare the database connection instance.

Parameters

Connection $connection
string $type

Return Value

protected Connection setPdoForType(Connection $connection, string|null $type = null)

Prepare the read / write mode for database connection instance.

Parameters

Connection $connection
string|null $type

Return Value

protected void registerConfiguredDoctrineTypes(Connection $connection)

Register custom Doctrine types with the connection.

Parameters

Connection $connection

Return Value

void

void registerDoctrineType(string $class, string $name, string $type)

Register a custom Doctrine type.

Parameters

string $class
string $name
string $type

Return Value

void

Exceptions

DBALException
RuntimeException

void purge(string|null $name = null)

Disconnect from the given database and remove from local cache.

Parameters

string|null $name

Return Value

void

void disconnect(string|null $name = null)

Disconnect from the given database.

Parameters

string|null $name

Return Value

void

Connection reconnect(string|null $name = null)

Reconnect to the given database.

Parameters

string|null $name

Return Value

mixed usingConnection(string $name, callable $callback)

Set the default database connection for the callback execution.

Parameters

string $name
callable $callback

Return Value

mixed

protected Connection refreshPdoConnections(string $name)

Refresh the PDO connections on a given connection.

Parameters

string $name

Return Value

string getDefaultConnection()

Get the default connection name.

Return Value

string

void setDefaultConnection(string $name)

Set the default connection name.

Parameters

string $name

Return Value

void

array supportedDrivers()

Get all of the support drivers.

Return Value

array

array availableDrivers()

Get all of the drivers that are actually available.

Return Value

array

void extend(string $name, callable $resolver)

Register an extension connection resolver.

Parameters

string $name
callable $resolver

Return Value

void

array getConnections()

Return all of the created connections.

Return Value

array

void setReconnector(callable $reconnector)

Set the database reconnector callback.

Parameters

callable $reconnector

Return Value

void

$this setApplication(Application $app)

Set the application instance used by the manager.

Parameters

Return Value

$this

mixed __call(string $method, array $parameters)

Dynamically pass methods to the default connection.

Parameters

string $method
array $parameters

Return Value

mixed

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