function optimizedb_optimize_batch_run in OptimizeDB 6
Same name and namespace in other branches
- 7 optimizedb.module \optimizedb_optimize_batch_run()
Batch function.
1 string reference to 'optimizedb_optimize_batch_run'
- optimizedb_admin_optimize_table_submit in ./
optimizedb.module - Implements hook_FORM_ID_submit().
File
- ./
optimizedb.module, line 586 - Database Optimization.
Code
function optimizedb_optimize_batch_run($table, &$context) {
// Standard the status the result operation.
$status = 'success';
switch (optimizedb_db_driver()) {
case 'mysql':
try {
$result = db_fetch_object(db_query('OPTIMIZE TABLE %s', $table));
if (isset($result->Msg_type) && in_array(strtolower($result->Msg_type), array(
'error',
'warning',
))) {
$status = 'error';
}
} catch (Exception $e) {
$status = 'error';
}
break;
case 'pgsql':
try {
db_query('VACUUM ANALYZE ' . $table);
} catch (Exception $e) {
$status = 'error';
}
break;
}
if (PHP_SAPI == 'cli') {
drush_print(dt('Table "@name" been optimized.', array(
'@name' => $table,
)));
}
$context['results'][$status][] = $table;
}