You are here

function _optimizedb_list_tables_operation_execute in OptimizeDB 7

Same name and namespace in other branches
  1. 8 optimizedb.module \_optimizedb_list_tables_operation_execute()
  2. 6 optimizedb.module \_optimizedb_list_tables_operation_execute()

Performing operations on tables.

Parameters

string $operation_name: The operation to be performed with tables.

See also

_optimizedb_list_tables_operation_execute_run()

3 calls to _optimizedb_list_tables_operation_execute()
optimizedb_list_tables_check_tables_submit in ./optimizedb.module
Form submission handler for optimizedb_list_tables().
optimizedb_list_tables_optimize_tables_submit in ./optimizedb.module
Form submission handler for optimizedb_list_tables().
optimizedb_list_tables_repair_tables_submit in ./optimizedb.module
Form submission handler for optimizedb_list_tables().

File

./optimizedb.module, line 467
Database Optimization.

Code

function _optimizedb_list_tables_operation_execute($form, $form_state, $operation_name) {
  $tables_selected = $form_state['values']['tables'];
  if (db_driver() == 'mysql') {
    if (!empty($tables_selected)) {
      $operations = array();
      foreach ($tables_selected as $table_name => $selected) {
        if ($table_name === $selected) {
          $operations[] = array(
            '_optimizedb_list_tables_operation_execute_run',
            array(
              array(
                'name' => $table_name,
                'operation' => $operation_name,
              ),
            ),
          );
        }
      }
      if (empty($operations)) {
        drupal_set_message(t('To execute, you must select at least one table from the list.'), 'error');
      }
      else {
        $batch = array(
          'operations' => $operations,
          'finished' => '_optimizedb_list_tables_operation_execute_finished',
        );
        batch_set($batch);
      }
    }
    else {
      drupal_set_message(t('To execute, you must select at least one table from the list.'), 'error');
    }
  }
  else {
    drupal_set_message(t('Function to check tables is only available for databases MySQL.'), 'error');
  }
}