\Installer\UtilityDatabaseInstaller

Handles database initialization for QuickAppsCMS's first installations.

Summary

Methods
Properties
Constants
__construct()
install()
error()
errors()
prepareConfig()
getConn()
importTables()
isDbEmpty()
writeSetting()
salt()
No public properties found
No constants found
_processFixture()
_importRecords()
_getRecords()
$_errors
$_installed
$_defaultConfig
$_defaultConnection
N/A
No private methods found
No private properties found
N/A

Properties

$_errors

$_errors : array

Error messages list.

Type

array

$_installed

$_installed : boolean

Whether the install() method was invoked or not.

Type

boolean

$_defaultConfig

$_defaultConfig : array

Default configuration for this class.

  • settingsPath: Full path to the "settings.php" file where store connection information used by QuickAppsCMS. This should NEVER be changed, use with caution.

  • schemaPath: Path to directory containing all tables information to be imported (fixtures).

  • maxExecutionTime: Time in seconds for PHP's "max_execution_time" directive. Defaults to 480 (8 minutes).

Type

array

$_defaultConnection

$_defaultConnection : array

Default database connection config.

Type

array

Methods

__construct()

__construct(array $config)

Constructor.

Parameters

array $config

Configuration options

install()

install(array $dbConfig) : boolean

Starts the process.

Parameters

array $dbConfig

Database connection information

Returns

boolean —

True on success, false otherwise

error()

error(string $message) : void

Registers an error message.

Parameters

string $message

The error message

errors()

errors() : array

Get all error messages.

Returns

array

prepareConfig()

prepareConfig(array $dbConfig) : boolean

Prepares database configuration attributes.

If the file "ROOT/config/settings.php.tmp" exists, and has declared a connection named "default" it will be used.

Parameters

array $dbConfig

Database connection info coming from POST

Returns

boolean —

True on success, false otherwise

getConn()

getConn() : \Cake\Database\Connection|boolean

Generates a new connection to DB.

Returns

\Cake\Database\Connection|boolean —

A connection object, or false on failure. On failure error messages are automatically set

importTables()

importTables(\Cake\Database\Connection $conn) : boolean

Imports tables schema and populates them.

Parameters

\Cake\Database\Connection $conn

Database connection to use

Returns

boolean —

True on success, false otherwise. On failure error messages are automatically set

isDbEmpty()

isDbEmpty(\Cake\Database\Connection $conn) : boolean

Checks whether connected database is empty or not.

Parameters

\Cake\Database\Connection $conn

Database connection to use

Returns

boolean —

True if database if empty and tables can be imported, false if there are some existing tables

writeSetting()

writeSetting() : boolean

Creates site's "settings.php" file.

Returns

boolean —

True on success

salt()

salt() : string

Generates a random string suitable for security's salt.

Returns

string

_processFixture()

_processFixture(string $path, \Cake\Database\Connection $connection) : boolean

Process the given fixture class, creates its schema and imports its records.

Parameters

string $path

Full path to schema class file

\Cake\Database\Connection $connection

Database connection to use

Returns

boolean —

True on success

_importRecords()

_importRecords(object $fixture, \Cake\Database\Schema\Table $schema, \Cake\Database\Connection $connection) : boolean

Imports all records of the given fixture.

Parameters

object $fixture

Fixture object instance

\Cake\Database\Schema\Table $schema

Table schema for which records will be imported

\Cake\Database\Connection $connection

Database connection to use

Returns

boolean —

True on success

_getRecords()

_getRecords(array $records, \Cake\Database\Schema\Table $schema) : array

Converts the given array of records into data used to generate a query.

Parameters

array $records

Records to be imported

\Cake\Database\Schema\Table $schema

Table schema for which records will be imported

Returns

array