Database
in package
Database Connection Factory
Creates and returns an instance of the appropriate Database Connection.
Table of Contents
Properties
- $connections : array<string|int, mixed>
- Maintains an array of the instances of all connections that have been created.
Methods
- load() : BaseConnection
- Parses the connection binds and creates a Database Connection instance.
- loadForge() : Forge
- Creates a Forge instance for the current database type.
- loadUtils() : BaseUtils
- Creates an instance of Utils for the current database type.
- initDriver() : BaseConnection|BaseUtils|Forge
- Creates a database object.
- parseDSN() : array<string|int, mixed>
- Parses universal DSN string
- checkDbExtension() : bool
- Check the PHP database extension is loaded.
Properties
$connections
Maintains an array of the instances of all connections that have been created.
protected
array<string|int, mixed>
$connections
= []
Helps to keep track of all open connections for performance monitoring, logging, etc.
Methods
load()
Parses the connection binds and creates a Database Connection instance.
public
load([array<string|int, mixed> $params = [] ][, string $alias = '' ]) : BaseConnection
Parameters
- $params : array<string|int, mixed> = []
- $alias : string = ''
Tags
Return values
BaseConnectionloadForge()
Creates a Forge instance for the current database type.
public
loadForge(ConnectionInterface $db) : Forge
Parameters
- $db : ConnectionInterface
Return values
ForgeloadUtils()
Creates an instance of Utils for the current database type.
public
loadUtils(ConnectionInterface $db) : BaseUtils
Parameters
- $db : ConnectionInterface
Return values
BaseUtilsinitDriver()
Creates a database object.
protected
initDriver(string $driver, string $class, array<string|int, mixed>|ConnectionInterface $argument) : BaseConnection|BaseUtils|Forge
Parameters
- $driver : string
-
Driver name. FQCN can be used.
- $class : string
-
'Connection'|'Forge'|'Utils'
- $argument : array<string|int, mixed>|ConnectionInterface
-
The constructor parameter or DB connection
Return values
BaseConnection|BaseUtils|ForgeparseDSN()
Parses universal DSN string
protected
parseDSN(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>checkDbExtension()
Check the PHP database extension is loaded.
private
checkDbExtension(string $driver) : bool
Parameters
- $driver : string
-
DB driver or FQCN for custom driver