function _optimizedb_list_tables_operation_execute in OptimizeDB 8
Same name and namespace in other branches
- 6 optimizedb.module \_optimizedb_list_tables_operation_execute()
- 7 optimizedb.module \_optimizedb_list_tables_operation_execute()
Performing operations on tables.
Parameters
array $tables: Tables names.
string $operation_name: The operation to be performed with tables.
See also
\Drupal\optimizedb\Form\OptimizedbListTablesForm::submitForm()
_optimizedb_list_tables_operation_execute_run()
2 calls to _optimizedb_list_tables_operation_execute()
- OptimizedbAdminForm::optimizeTablesSubmit in src/
Form/ OptimizedbAdminForm.php - Optimize all tables in database.
- OptimizedbListTablesForm::submitForm in src/
Form/ OptimizedbListTablesForm.php - Form submission handler.
File
- ./
optimizedb.module, line 58 - Database Optimization.
Code
function _optimizedb_list_tables_operation_execute(array $tables, $operation_name) {
if (\Drupal::database()
->driver() == 'mysql') {
if (!empty($tables)) {
$operations = [];
foreach ($tables as $table_name => $selected) {
if ($table_name === $selected) {
$operations[] = [
'_optimizedb_list_tables_operation_execute_run',
[
[
'name' => $table_name,
'operation' => $operation_name,
],
],
];
}
}
if (empty($operations)) {
\Drupal::messenger()
->addError(t('To execute, you must select at least one table from the list.'));
}
else {
$batch = [
'operations' => $operations,
'finished' => '_optimizedb_list_tables_operation_execute_finished',
];
batch_set($batch);
}
}
else {
\Drupal::messenger()
->addError(t('To execute, you must select at least one table from the list.'));
}
}
else {
\Drupal::messenger()
->addError(t('Function to check tables is only available for databases MySQL.'));
}
}