Moodle 2.0.3 release
[moodle.git] / admin / innodb.php
blob47fcf09ae5c7a03294fbd15432e287f6d0aef541
1 <?php
3 require_once('../config.php');
4 require_once($CFG->libdir.'/adminlib.php');
6 admin_externalpage_setup('toinodb');
8 $confirm = optional_param('confirm', 0, PARAM_BOOL);
10 require_login();
12 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
14 echo $OUTPUT->header();
15 echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB');
17 if ($DB->get_dbfamily() != 'mysql') {
18 notice('This function is for MySQL databases only!', 'index.php');
21 if (data_submitted() and $confirm and confirm_sesskey()) {
23 echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
25 if ($tables = $DB->get_tables()) {
26 $DB->set_debug(true);
27 foreach ($tables as $table) {
28 $fulltable = $DB->get_prefix().$table;
29 $DB->change_database_structure("ALTER TABLE $fulltable TYPE=INNODB");
31 $DB->set_debug(false);
33 echo $OUTPUT->notification('... done.', 'notifysuccess');
34 echo $OUTPUT->continue_button('index.php');
35 echo $OUTPUT->footer();
37 } else {
38 $optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
39 $formcontinue = new single_button(new moodle_url('/admin/innodb.php', $optionsyes), get_string('yes'));
40 $formcancel = new single_button(new moodle_url('/admin/index.php'), get_string('no'), 'get');
41 echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel);
42 echo $OUTPUT->footer();