You are here

function optimizedb_admin_optimize_table_submit in OptimizeDB 6

Same name and namespace in other branches
  1. 7 optimizedb.module \optimizedb_admin_optimize_table_submit()

Implements hook_FORM_ID_submit().

1 call to optimizedb_admin_optimize_table_submit()
drush_optimizedb_optimize in includes/optimizedb.drush.inc
Optimizing the tables.
1 string reference to 'optimizedb_admin_optimize_table_submit'
optimizedb_admin in ./optimizedb.module
Configuring the module.

File

./optimizedb.module, line 550
Database Optimization.

Code

function optimizedb_admin_optimize_table_submit($form, &$form_state) {
  switch (optimizedb_db_driver()) {
    case 'mysql':
      $tables = db_query("SHOW TABLES");
      break;
    case 'pgsql':
      $tables = db_query("SELECT table_name\n        FROM information_schema.tables\n        WHERE table_schema = 'public'\n        ORDER BY table_name");
      break;
  }
  while ($table = db_fetch_array($tables)) {
    $table = array_values($table);
    $operations[] = array(
      'optimizedb_optimize_batch_run',
      array(
        $table[0],
      ),
    );
  }
  $batch = array(
    'operations' => $operations,
    'finished' => 'optimizedb_optimize_batch_finished',
  );
  batch_set($batch);

  // Calling this function, you need to run the optimization from
  // the command line.
  if (PHP_SAPI == 'cli') {
    drush_backend_batch_process();
  }
}