function apdqc_admin_convert_innodb_tables_to_files in Asynchronous Prefetch Database Query Cache 7
Convert innodb tables to be stored per file.
Parameters
bool $show_msg: Set to FALSE to not run drupal_set_message().
1 string reference to 'apdqc_admin_convert_innodb_tables_to_files'
- apdqc_admin_operations_form in ./
apdqc.admin.inc - Form builder; perform apdqc operations.
File
- ./
apdqc.admin.inc, line 618 - Admin page callbacks for the apdqc module.
Code
function apdqc_admin_convert_innodb_tables_to_files($show_msg = TRUE) {
$db_type = Database::getConnection()
->databaseType();
if ($db_type !== 'mysql') {
return;
}
$db = Database::getConnection()
->getConnectionOptions();
$innodb_tables = db_query("\n SELECT\n table_name,\n engine\n FROM information_schema.tables\n WHERE TABLE_SCHEMA = :dbname\n AND TABLE_TYPE = 'BASE TABLE'\n AND ENGINE = 'InnoDB'\n ", array(
':dbname' => $db['database'],
))
->fetchAllAssoc('table_name');
foreach ($innodb_tables as $row) {
db_query("ALTER TABLE `{$row->table_name}` DISABLE KEYS;");
db_query("ALTER TABLE `{$row->table_name}` ENGINE = InnoDB;");
db_query("ALTER TABLE `{$row->table_name}` ENABLE KEYS;");
}
// Let user know it worked.
if ($show_msg !== FALSE) {
drupal_set_message(t('APDQC: All InnoDB tables are file per table.'));
}
variable_del('apdqc_innodb_file_per_table');
}