class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper (View source)

This is a helper class for the SS installer.

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

Methods

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

Create a connection of the appropriate type

protected
array
column(mixed $results)

Helper function to quickly extract a column from a mysqi_result

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
string
getDatabaseVersion(array $databaseConfig)

Determines the version of the database server

public
array
requireDatabaseVersion(array $databaseConfig)

Ensure that the MySQL server version is at least 5.0.

public
array
requireDatabaseConnection(array $databaseConfig)

Ensure a database connection is possible using credentials provided.

public
bool
checkValidDatabaseName(string $database)

Determines if a given database name is a valid Silverstripe name.

public
bool
checkDatabasePermissionGrant(string $database, string $permission, string $grant)

Checks if a specified grant proves that the current user has the specified permission on the specified database

public
bool
checkDatabasePermission(mixed $conn, string $database, string $permission)

Checks if the current user has the specified permission on the specified database

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
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

protected array column(mixed $results)

Helper function to quickly extract a column from a mysqi_result

Parameters

mixed $results

mysqli_result or enumerable list of rows

Return Value

array

Resulting data

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')

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)

Ensure that the MySQL server version is at least 5.0.

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 requireDatabaseConnection(array $databaseConfig)

Ensure a database connection is possible using credentials provided.

The established connection resource is returned with the results as well.

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')

bool checkValidDatabaseName(string $database)

Determines if a given database name is a valid Silverstripe name.

Parameters

string $database

Candidate database name

Return Value

bool

bool checkDatabasePermissionGrant(string $database, string $permission, string $grant)

Checks if a specified grant proves that the current user has the specified permission on the specified database

Parameters

string $database

Database name

string $permission

Permission to check for

string $grant

MySQL syntax grant to check within

Return Value

bool

bool checkDatabasePermission(mixed $conn, string $database, string $permission)

Checks if the current user has the specified permission on the specified database

Parameters

mixed $conn

Connection object

string $database

Database name

string $permission

Permission to check

Return Value

bool

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')

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