Database
extends Config
in package
Database Configuration
Table of Contents
- $default : array<string|int, mixed>
- The default database connection.
- $defaultGroup : string
- Lets you choose which connection group to use if no other is specified.
- $filesPath : string
- The directory that holds the Migrations and Seeds directories.
- $registrars : array<string|int, mixed>
- An optional array of classes that will act as Registrars for rapidly setting config class properties.
- $tests : array<string|int, mixed>
- This database connection is used when running PHPUnit database tests.
- $didDiscovery : bool
- Has module discovery happened yet?
- $factory : Database|null
- The main instance used to manage all of our open database connections.
- $instances : array<string|int, mixed>
- Cache for instance of any connections that have been requested as a "shared" instance.
- $moduleConfig : Modules
- The modules configuration.
- __construct() : mixed
- connect() : BaseConnection
- Creates the default
- forge() : Forge
- Loads and returns an instance of the Forge for the specified database group, and loads the group if it hasn't been loaded yet.
- getConnections() : array<string|int, mixed>
- Returns an array of all db connections currently made.
- seeder() : Seeder
- Returns a new instance of the Database Seeder.
- utils() : BaseUtils
- Returns a new instance of the Database Utilities class.
- ensureFactory() : mixed
- Ensures the database Connection Manager/Factory is loaded and ready to use.
- getEnvValue() : mixed
- Retrieve an environment-specific configuration setting
- initEnvValue() : mixed
- Initialization an environment-specific configuration setting
- registerProperties() : mixed
- Provides external libraries a simple way to register one or more options into a config file.
Properties
$default
The default database connection.
public
array<string|int, mixed>
$default
= ['DSN' => '', 'hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'busbrainplus', 'DBDriver' => 'MySQLi', 'DBPrefix' => '', 'pConnect' => false, 'DBDebug' => ENVIRONMENT !== 'development', 'charset' => 'utf8', 'DBCollat' => 'utf8_general_ci', 'swapPre' => '', 'encrypt' => false, 'compress' => false, 'strictOn' => false, 'failover' => [], 'port' => 3306]
$defaultGroup
Lets you choose which connection group to use if no other is specified.
public
string
$defaultGroup
= 'default'
$filesPath
The directory that holds the Migrations and Seeds directories.
public
string
$filesPath
= APPPATH . 'Database' . DIRECTORY_SEPARATOR
$registrars
An optional array of classes that will act as Registrars for rapidly setting config class properties.
public
static array<string|int, mixed>
$registrars
= []
$tests
This database connection is used when running PHPUnit database tests.
public
array<string|int, mixed>
$tests
= [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_',
// Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => ENVIRONMENT !== 'development',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
]
$didDiscovery
Has module discovery happened yet?
protected
static bool
$didDiscovery
= false
$factory
The main instance used to manage all of our open database connections.
protected
static Database|null
$factory
$instances
Cache for instance of any connections that have been requested as a "shared" instance.
protected
static array<string|int, mixed>
$instances
= []
$moduleConfig
The modules configuration.
protected
static Modules
$moduleConfig
Methods
__construct()
public
__construct() : mixed
Return values
mixed —connect()
Creates the default
public
static connect([string|array<string|int, mixed> $group = null ][, bool $getShared = true ]) : BaseConnection
Parameters
- $group : string|array<string|int, mixed> = null
-
The name of the connection group to use, or an array of configuration settings.
- $getShared : bool = true
-
Whether to return a shared instance of the connection.
Return values
BaseConnection —forge()
Loads and returns an instance of the Forge for the specified database group, and loads the group if it hasn't been loaded yet.
public
static forge([ConnectionInterface|string|array<string|int, mixed>|null $group = null ]) : Forge
Parameters
- $group : ConnectionInterface|string|array<string|int, mixed>|null = null
Return values
Forge —getConnections()
Returns an array of all db connections currently made.
public
static getConnections() : array<string|int, mixed>
Return values
array<string|int, mixed> —seeder()
Returns a new instance of the Database Seeder.
public
static seeder([string|null $group = null ]) : Seeder
Parameters
- $group : string|null = null
Return values
Seeder —utils()
Returns a new instance of the Database Utilities class.
public
static utils([string|array<string|int, mixed>|null $group = null ]) : BaseUtils
Parameters
- $group : string|array<string|int, mixed>|null = null
Return values
BaseUtils —ensureFactory()
Ensures the database Connection Manager/Factory is loaded and ready to use.
protected
static ensureFactory() : mixed
Return values
mixed —getEnvValue()
Retrieve an environment-specific configuration setting
protected
getEnvValue(string $property, string $prefix, string $shortPrefix) : mixed
Parameters
- $property : string
- $prefix : string
- $shortPrefix : string
Return values
mixed —initEnvValue()
Initialization an environment-specific configuration setting
protected
initEnvValue(mixed &$property, string $name, string $prefix, string $shortPrefix) : mixed
Parameters
- $property : mixed
- $name : string
- $prefix : string
- $shortPrefix : string
Return values
mixed —registerProperties()
Provides external libraries a simple way to register one or more options into a config file.
protected
registerProperties() : mixed