class SQLiteDatabaseConfigurationHelper implements DatabaseConfigurationHelper (View source)

This is a helper class for the SS installer.

It does all the specific checking for SQLiteDatabase to ensure that the configuration is setup correctly.

Methods

protected
mixed|null
createConnection(array $databaseConfig, string $error)

Create a connection of the appropriate type

public
bool
requireDatabaseFunctions(array $databaseConfig)

Ensure that the database function for connectivity is available.

public
array
requireDatabaseServer(array $databaseConfig)

Ensure that the database server exists.

public
array
requireDatabaseConnection(array $databaseConfig)

Ensure a database connection is possible using credentials provided.

public
string
getDatabaseVersion(array $databaseConfig)

Determines the version of the database server

public
array
requireDatabaseVersion(array $databaseConfig)

Check database version is greater than the minimum supported

public
array
requireDatabaseOrCreatePermissions(array $databaseConfig)

Ensure that the database connection is able to use an existing database, or be able to create one if it doesn't exist.

public static 
bool
create_db_dir(string $path)

Creates the provided directory and prepares it for storing SQLlite. Use secure_db_dir() to secure it against unauthorized access.

public static 
bool
secure_db_dir(string $path)

Secure the provided directory via web-access by placing a .htaccess file in it.

public
array
requireDatabaseAlterPermissions(array $databaseConfig)

Ensure we have permissions to alter tables.

Details

protected mixed|null createConnection(array $databaseConfig, string $error)

Create a connection of the appropriate type

Parameters

array $databaseConfig
string $error

Error message passed by value

Return Value

mixed|null

Either the connection object, or null if error

bool requireDatabaseFunctions(array $databaseConfig)

Ensure that the database function for connectivity is available.

If it is, we assume the PHP module for this database has been setup correctly.

Parameters

array $databaseConfig

Associative array of db configuration, e.g. "server", "username" etc

Return Value

bool

array requireDatabaseServer(array $databaseConfig)

Ensure that the database server exists.

Parameters

array $databaseConfig

Associative array of db configuration, e.g. "server", "username" etc

Return Value

array

Result - e.g. array('okay' => true, 'error' => 'details of error')

array requireDatabaseConnection(array $databaseConfig)

Ensure a database connection is possible using credentials provided.

Validate path

Parameters

array $databaseConfig

Associative array of db configuration, e.g. "server", "username" etc

Return Value

array

Result - e.g. array('okay' => true, 'connection' => mysql link, 'error' => 'details of error')

string getDatabaseVersion(array $databaseConfig)

Determines the version of the database server

Parameters

array $databaseConfig

Associative array of db configuration, e.g. "server", "username" etc

Return Value

string

Version of database server or false on failure

array requireDatabaseVersion(array $databaseConfig)

Check database version is greater than the minimum supported

Parameters

array $databaseConfig

Associative array of db configuration, e.g. "server", "username" etc

Return Value

array

Result - e.g. array('success' => true, 'error' => 'details of error')

array requireDatabaseOrCreatePermissions(array $databaseConfig)

Ensure that the database connection is able to use an existing database, or be able to create one if it doesn't exist.

Parameters

array $databaseConfig

Associative array of db configuration, e.g. "server", "username" etc

Return Value

array

Result - e.g. array('okay' => true, 'existsAlready' => 'true')

static bool create_db_dir(string $path)

Creates the provided directory and prepares it for storing SQLlite. Use secure_db_dir() to secure it against unauthorized access.

Parameters

string $path

Absolute path, usually with a hidden folder.

Return Value

bool

static bool secure_db_dir(string $path)

Secure the provided directory via web-access by placing a .htaccess file in it.

This is just required if the database directory is placed within a publically accessible webroot (the default path is in a hidden folder within assets/).

Parameters

string $path

Absolute path, containing a SQLite datatbase

Return Value

bool

array requireDatabaseAlterPermissions(array $databaseConfig)

Ensure we have permissions to alter tables.

Parameters

array $databaseConfig

Associative array of db configuration, e.g. "server", "username" etc

Return Value

array

Result - e.g. array('okay' => true, 'applies' => true), where applies is whether the test is relevant for the database