function _paranoiasanitize_apply_db_prefix in Paranoia 7
Given an array of tables and a database config, apply prefixes.
Parameters
string $table_name: A table name.
array $databases: A Drupal database configuration array.
Return value
string Same content as $table_name, but with a prefix if needed.
1 call to _paranoiasanitize_apply_db_prefix()
- ParanoiaSanitizeTestCase::testDecideTablePrefixing in paranoiasanitize/
paranoiasanitize.test - Confirm prefixes are properly added to tables.
File
- paranoiasanitize/
paranoiasanitize.module, line 71 - Functions to support the drush file. Located here to support testing.
Code
function _paranoiasanitize_apply_db_prefix($table_name, $databases) {
if (!empty($databases['default']['default']['prefix'])) {
$prefixes = $databases['default']['default']['prefix'];
if (array_key_exists($table_name, $prefixes)) {
return $prefixes[$table_name] . $table_name;
}
elseif (!empty($prefixes['default'])) {
return $prefixes['default'] . $table_name;
}
else {
return $table_name;
}
}
return $table_name;
}