innodb.php 1.39 KB
Newer Older
1
2
<?php

3
4
    require_once('../config.php');
    require_once($CFG->libdir.'/adminlib.php');
5

6
    admin_externalpage_setup('toinodb');
skodak's avatar
skodak committed
7

8
    $confirm = optional_param('confirm', 0, PARAM_BOOL);
9

10
    require_login();
11

12
    require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
13

14
    admin_externalpage_print_header();
15
    echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB');
16

17
    if ($DB->get_dbfamily() != 'mysql') {
18
        notice('This function is for MySQL databases only!', 'index.php');
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    }

    if (data_submitted() and $confirm and confirm_sesskey()) {

        notify('Please be patient and wait for this to complete...', 'notifysuccess');

        if ($tables = $DB->get_tables()) {
            $DB->set_debug(true);
            foreach ($tables as $table) {
                $fulltable = $DB->get_prefix().$table;
                $DB->change_database_structure("ALTER TABLE $fulltable TYPE=INNODB");
            }
            $DB->set_debug(false);
        }
        notify('... done.', 'notifysuccess');
        print_continue('index.php');
35
        echo $OUTPUT->footer();
36
37
38
39
40

    } else {
        $optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
        notice_yesno('Are you sure you want convert all your tables to the InnoDB format?',
                     'innodb.php', 'index.php', $optionsyes, NULL, 'post', 'get');
41
        echo $OUTPUT->footer();
42
    }
43
44

?>