function optimizedb_admin_optimize_table_submit in OptimizeDB 7
Same name and namespace in other branches
- 6 optimizedb.module \optimizedb_admin_optimize_table_submit()
Form submission handler for optimizedb_admin().
Optimization of all database tables. Getting a list of all tables and transfer of each table in the batch.
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 649 - Database Optimization.
Code
function optimizedb_admin_optimize_table_submit($form, &$form_state) {
$tables = array();
switch (db_driver()) {
case 'mysql':
$tables = db_query("SHOW TABLES", array(), array(
'fetch' => PDO::FETCH_NUM,
));
break;
case 'pgsql':
$tables = db_query("SELECT table_name\n FROM information_schema.tables\n WHERE table_schema = 'public'\n ORDER BY table_name", array(), array(
'fetch' => PDO::FETCH_NUM,
));
break;
}
$operations = array();
foreach ($tables as $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();
}
}