. /** * InnoDB conversion tool. * * @package tool * @subpackage innodb * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('NO_OUTPUT_BUFFERING', true); require_once('../../../config.php'); require_once($CFG->libdir.'/adminlib.php'); admin_externalpage_setup('toolinnodb'); $confirm = optional_param('confirm', 0, PARAM_BOOL); echo $OUTPUT->header(); echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB'); if ($DB->get_dbfamily() != 'mysql') { notice('This function is for MySQL databases only!', new moodle_url('/admin/')); } $prefix = str_replace('_', '\\_', $DB->get_prefix()).'%'; $sql = "SHOW TABLE STATUS WHERE Name LIKE ? AND Engine <> 'InnoDB'"; $rs = $DB->get_recordset_sql($sql, array($prefix)); if (!$rs->valid()) { $rs->close(); echo $OUTPUT->box('
All tables are already using InnoDB database engine.
'); echo $OUTPUT->continue_button('/admin/'); echo $OUTPUT->footer(); die; } if (data_submitted() and $confirm and confirm_sesskey()) { echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess'); core_php_time_limit::raise(); foreach ($rs as $table) { $DB->set_debug(true); $fulltable = $table->name; try { $DB->change_database_structure("ALTER TABLE $fulltable ENGINE=INNODB"); } catch (moodle_exception $e) { echo $OUTPUT->notification(s($e->getMessage()).'