Database
class Database
Class Database
Traits
Properties
static protected bool | $singletonArray | Set to true if you want use more that one singleton using and index param in getInstance | from Singleton |
static protected string | $basePath | The base path where config files are placed. | from Singleton |
static private string | $className | Name of the class | from Singleton |
static private array | $instances | Hold the classes on instance. | from Singleton |
protected bool | $separateConfigFile | Set to true if you want to save configuration in a separate file | from Singleton |
protected Engine | $dbEngine | Contains the instance to the database engine (or null) | |
protected sqlHelper | $sqlHelper | Contains the instance to the specific SQL engine helper (or null) | |
protected array | $config | Array of config data |
Methods
Return this instance.
Save config to file.
Return default values
Initialization, equivalent to __construct and must be called from main class.
Database constructor.
If Database::getInstance()->getDbEngine() contain null, create an Engine instance with the database connection and assigns it to Database::getInstance()->getDbEngine().
Returns the database engine.
Return the sql helper for the engine in use.
Returns the connections data details.
Details
at line 88
static
Database
getInstance()
Return this instance.
in
Singleton
at line 88
static private string
getClassName()
Returns the class name.
in
Singleton
at line 103
bool
setConfig(array $params, bool $merge = true, string $index = 'main')
Save config to file.
in
Singleton
at line 130
private array
getYamlContent()
Returns the content of the Yaml file.
in
Singleton
at line 152
string
getFilePath()
Return the full file config path.
in
Singleton
at line 162
string
getFileName()
Return the file name.
in
Singleton
at line 172
static string
yamlName()
Return the classname for yaml file.
in
Singleton
at line 184
protected bool
fileExists(string $filename)
Returns if file exists.
in
Singleton
at line 196
array
getConfig(string $index = 'main')
Returns the yaml config params.
at line 98
static array
getDefaultValues()
Return default values
in
Singleton
at line 215
string
getBasePath()
Return the base path.
in
Singleton
at line 223
protected
initSingleton()
Initialization, equivalent to __construct and must be called from main class.
at line 49
__construct()
Database constructor.
at line 117
bool
connectToDatabase()
If Database::getInstance()->getDbEngine() contain null, create an Engine instance with the database connection and assigns it to Database::getInstance()->getDbEngine().
at line 127
Engine|null
getDbEngine()
Returns the database engine.
at line 140
SqlHelper
getSqlHelper()
Return the sql helper for the engine in use.
at line 153
array
getConnectionData()
Returns the connections data details.