public function DatabaseTasks::validateDatabaseSettings in Drupal 7
Validates driver specific configuration settings.
Checks to ensure correct basic database settings and that a proper connection to the database can be established.
Parameters
$database: An array of driver specific configuration options.
Return value
An array of driver configuration errors, keyed by form element name.
1 call to DatabaseTasks::validateDatabaseSettings()
- DatabaseTasks_sqlite::validateDatabaseSettings in includes/
database/ sqlite/ install.inc - Validates driver specific configuration settings.
1 method overrides DatabaseTasks::validateDatabaseSettings()
- DatabaseTasks_sqlite::validateDatabaseSettings in includes/
database/ sqlite/ install.inc - Validates driver specific configuration settings.
File
- includes/
install.inc, line 560 - API functions for installing modules and themes.
Class
- DatabaseTasks
- Database installer structure.
Code
public function validateDatabaseSettings($database) {
$errors = array();
// Verify the table prefix.
if (!empty($database['prefix']) && is_string($database['prefix']) && !preg_match('/^[A-Za-z0-9_.]+$/', $database['prefix'])) {
$errors[$database['driver'] . '][advanced_options][db_prefix'] = st('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array(
'%prefix' => $database['prefix'],
));
}
// Verify the database port.
if (!empty($database['port']) && !is_numeric($database['port'])) {
$errors[$database['driver'] . '][advanced_options][port'] = st('Database port must be a number.');
}
return $errors;
}