function optimizedb_list_tables in OptimizeDB 6
Same name and namespace in other branches
- 7 optimizedb.module \optimizedb_list_tables()
List of tables in the database with the size and sorting.
Return value
string Table with a list of tables.
1 string reference to 'optimizedb_list_tables'
- optimizedb_menu in ./
optimizedb.module - Implements hook_menu().
File
- ./
optimizedb.module, line 226 - Database Optimization.
Code
function optimizedb_list_tables() {
$form = array();
$form['header'] = array(
'#type' => 'value',
'#value' => array(
theme('table_select_header_cell'),
array(
'data' => t('Table name'),
),
array(
'data' => t('Table size'),
'field' => 'size',
'sort' => 'asc',
),
),
);
$rows = _optimizedb_tables_list();
usort($rows, '_optimizedb_list_tables_sort');
$operations_tables_result = isset($_SESSION['optimizedb_list_tables_operations']) ? $_SESSION['optimizedb_list_tables_operations'] : NULL;
if (!is_null($operations_tables_result)) {
if ($operations_tables_result == array()) {
drupal_set_message(t('The operation completed successfully.'));
}
else {
$form['operations_tables'] = array(
'#type' => 'fieldset',
'#title' => t('Errors that arose during the operation:'),
);
$header_errors = array(
array(
'data' => t('Table name'),
),
array(
'data' => t('Type of problem'),
),
array(
'data' => t('Information about the problem'),
),
);
$form['operations_tables']['errors'] = array(
'#value' => theme('table', $header_errors, $operations_tables_result),
);
}
}
$_SESSION['optimizedb_list_tables_operations'] = NULL;
if (optimizedb_db_driver() == 'mysql') {
$form['operations'] = array(
'#type' => 'fieldset',
'#title' => t('Operations with tables:'),
);
$form['operations']['check_tables'] = array(
'#type' => 'submit',
'#value' => t('Check tables'),
'#submit' => array(
'optimizedb_list_tables_check_tables_submit',
),
);
$form['operations']['repair_tables'] = array(
'#type' => 'submit',
'#value' => t('Repair tables'),
'#submit' => array(
'optimizedb_list_tables_repair_tables_submit',
),
);
$form['operations']['optimize_tables'] = array(
'#type' => 'submit',
'#value' => t('Optimize tables'),
'#submit' => array(
'optimizedb_list_tables_optimize_tables_submit',
),
);
}
if (!empty($rows)) {
foreach ($rows as $row) {
$options[$row['name']] = '';
$form['name'][$row['name']] = array(
'#value' => $row['name'],
);
$form['size'][$row['name']] = array(
'#value' => $row['size'],
);
}
}
$form['tables'] = array(
'#type' => 'checkboxes',
'#options' => isset($options) ? $options : array(),
);
return $form;
}