DatabaseManager

class DatabaseManager implements ConnectionResolverInterface (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.

Methods

void __construct(Application $app, ConnectionFactory $factory)

Create a new database manager instance.

Connection connection(string $name = null)

Get a database connection instance.

array parseConnectionName(string $name)

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

void purge(string $name = null)

Disconnect from the given database and remove from local cache.

void disconnect(string $name = null)

Disconnect from the given database.

Connection reconnect(string $name = null)

Reconnect to the given database.

Connection refreshPdoConnections(string $name)

Refresh the PDO connections on a given connection.

Connection makeConnection(string $name)

Make the database connection instance.

Connection prepare(Connection $connection)

Prepare the database connection instance.

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

Prepare the read write mode for database connection instance.

array getConfig(string $name)

Get the configuration for a connection.

string getDefaultConnection()

Get the default connection name.

void setDefaultConnection(string $name)

Set the default connection name.

void extend(string $name, callable $resolver)

Register an extension connection resolver.

array getConnections()

Return all of the created connections.

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

Application $app
ConnectionFactory $factory

Return Value

void

Connection connection(string $name = null)

Get a database connection instance.

Parameters

string $name

Return Value

Connection

protected array parseConnectionName(string $name)

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

Parameters

string $name

Return Value

array

void purge(string $name = null)

Disconnect from the given database and remove from local cache.

Parameters

string $name

Return Value

void

void disconnect(string $name = null)

Disconnect from the given database.

Parameters

string $name

Return Value

void

Connection reconnect(string $name = null)

Reconnect to the given database.

Parameters

string $name

Return Value

Connection

protected Connection refreshPdoConnections(string $name)

Refresh the PDO connections on a given connection.

Parameters

string $name

Return Value

Connection

protected Connection makeConnection(string $name)

Make the database connection instance.

Parameters

string $name

Return Value

Connection

protected Connection prepare(Connection $connection)

Prepare the database connection instance.

Parameters

Connection $connection

Return Value

Connection

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

Prepare the read write mode for database connection instance.

Parameters

Connection $connection
string $type

Return Value

Connection

protected array getConfig(string $name)

Get the configuration for a connection.

Parameters

string $name

Return Value

array

Exceptions

InvalidArgumentException

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

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

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/4.2/Illuminate/Database/DatabaseManager.html