1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * InnoDB conversion tool. 19 * 20 * @package tool 21 * @subpackage innodb 22 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 define('NO_OUTPUT_BUFFERING', true); 27 28 require_once('../../../config.php'); 29 require_once($CFG->libdir.'/adminlib.php'); 30 31 admin_externalpage_setup('toolinnodb'); 32 33 $confirm = optional_param('confirm', 0, PARAM_BOOL); 34 35 36 echo $OUTPUT->header(); 37 echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB'); 38 39 if ($DB->get_dbfamily() != 'mysql') { 40 notice('This function is for MySQL databases only!', new moodle_url('/admin/')); 41 } 42 43 $prefix = str_replace('_', '\\_', $DB->get_prefix()).'%'; 44 $sql = "SHOW TABLE STATUS WHERE Name LIKE ? AND Engine <> 'InnoDB'"; 45 $rs = $DB->get_recordset_sql($sql, array($prefix)); 46 if (!$rs->valid()) { 47 $rs->close(); 48 echo $OUTPUT->box('<p>All tables are already using InnoDB database engine.</p>'); 49 echo $OUTPUT->continue_button('/admin/'); 50 echo $OUTPUT->footer(); 51 die; 52 } 53 54 if (data_submitted() and $confirm and confirm_sesskey()) { 55 56 echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess'); 57 58 core_php_time_limit::raise(); 59 60 foreach ($rs as $table) { 61 $DB->set_debug(true); 62 $fulltable = $table->name; 63 try { 64 $DB->change_database_structure("ALTER TABLE $fulltable ENGINE=INNODB"); 65 } catch (moodle_exception $e) { 66 echo $OUTPUT->notification(s($e->getMessage()).'<br />'.s($e->debuginfo)); 67 } 68 $DB->set_debug(false); 69 } 70 $rs->close(); 71 echo $OUTPUT->notification('... done.', 'notifysuccess'); 72 echo $OUTPUT->continue_button(new moodle_url('/admin/')); 73 echo $OUTPUT->footer(); 74 75 } else { 76 $rs->close(); 77 $optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey()); 78 $formcontinue = new single_button(new moodle_url('/admin/tool/innodb/index.php', $optionsyes), get_string('yes')); 79 $formcancel = new single_button(new moodle_url('/admin/'), get_string('no'), 'get'); 80 echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel); 81 echo $OUTPUT->footer(); 82 } 83 84
title
Description
Body
title
Description
Body
title
Description
Body
title
Body