本文整理汇总了PHP中drop_table函数的典型用法代码示例。如果您正苦于以下问题:PHP drop_table函数的具体用法?PHP drop_table怎么用?PHP drop_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_artefact_calendar_upgrade
function xmldb_artefact_calendar_upgrade($oldversion = 0)
{
if ($oldversion < 2013062404) {
$table = new XMLDBTable('artefact_calendar_reminder');
drop_table($table);
$table->addFieldInfo('user', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('reminder_type', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL);
$table->addFieldInfo('reminder_date', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '-1', null);
$table->addKeyInfo('reminder_pk', XMLDB_KEY_PRIMARY, array('user'));
if (!create_table($table)) {
throw new SQLException($table . " could not be created, check log for errors.");
}
execute_sql('ALTER TABLE {artefact_calendar_calendar} DROP COLUMN {reminder_status}');
}
if ($oldversion < 2013062501) {
execute_sql('ALTER TABLE {artefact_calendar_calendar} change {reminder_date} {reminder_date} int(4) NOT NULL;');
}
if ($oldversion < 2013063001) {
$table = new XMLDBTable('artefact_calendar_event');
$table->addFieldInfo('eventid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('begin', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('end', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('whole_day', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL);
$table->addFieldInfo('repeat_type', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL);
$table->addFieldInfo('repeats_every', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL);
$table->addFieldInfo('end_date', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('ends_after', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL);
$table->addKeyInfo('event_pk', XMLDB_KEY_PRIMARY, array('eventid'));
if (!create_table($table)) {
throw new SQLException($table . " could not be created, check log for errors.");
}
}
return true;
}
示例2: drop_all_deck
function drop_all_deck()
{
global $DECK_TABLE_NAME;
$all_deck_ids = get_attribute_values($DECK_TABLE_NAME, "id");
foreach ($all_deck_ids as $id) {
$deck_table_name = get_deck_table_name($id);
drop_table($deck_table_name);
print_msg("drop {$deck_table_name}");
}
}
示例3: question_remove_rqp_qtype
function question_remove_rqp_qtype()
{
global $CFG;
$result = true;
// Only remove the question type if the code is gone.
if (!is_dir($CFG->dirroot . '/question/type/rqp')) {
$table = new XMLDBTable('question_rqp_states');
$result = $result && drop_table($table);
$table = new XMLDBTable('question_rqp');
$result = $result && drop_table($table);
$table = new XMLDBTable('question_rqp_types');
$result = $result && drop_table($table);
$table = new XMLDBTable('question_rqp_servers');
$result = $result && drop_table($table);
$result = $result && unset_config('qtype_rqp_version');
}
return $result;
}
示例4: xmldb_format_topcoll_upgrade
/**
* Collapsed Topics Information
*
* A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics
* except zero have a toggle that displays that topic. One or more topics can be displayed at any given time.
* Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small
* code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file.
*
* @package course/format
* @subpackage topcoll
* @version See the value of '$plugin->version' in below.
* @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
* @link http://docs.moodle.org/en/Collapsed_Topics_course_format
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function xmldb_format_topcoll_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2012030200) {
// Define table format_topcoll_layout.
$table = new XMLDBTable('format_topcoll_layout');
// Drop it if it existed before
drop_table($table, true, false);
// Adding fields.
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, '0', null);
$table->addFieldInfo('layoutelement', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, '1', null);
$table->addFieldInfo('layoutstructure', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, '1', null);
// Adding key.
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
// Create table.
$result = $result && create_table($table);
}
return $result;
}
示例5: drop_tables
function drop_tables()
{
drop_table("dota2_ability_upgrades");
// Drop ability upgrades
drop_table("dota2_additional_units");
// Drop additional units
drop_table("dota2_items");
// Drop items
drop_table("dota2_leagues");
// Drop leagues
drop_table("dota2_prize_pools");
// Drop prize pools
drop_table("dota2_matches");
// Drop matches
drop_table("dota2_picks_bans");
// Drop picks & bans
drop_table("dota2_slots");
// Drop slots
drop_table("dota2_users");
// Drop users
drop_table("dota2_teams");
// Drop teams
}
示例6: uninstall_from_xmldb_file
/**
* This function will load one entire XMLDB file, generating all the needed
* SQL statements, specific for each RDBMS ($CFG->dbtype) and, finally, it
* will execute all those statements against the DB, to drop all tables.
*
* @param $file full path to the XML file to be used
* @return boolean (true on success, false on error)
*/
function uninstall_from_xmldb_file($file)
{
global $CFG, $db;
$status = true;
$xmldb_file = new XMLDBFile($file);
if (!$xmldb_file->fileExists()) {
throw new InstallationException($xmldb_file->path . " doesn't exist.");
}
$loaded = $xmldb_file->loadXMLStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
throw new InstallationException("Could not load " . $xmldb_file->path);
}
$structure = $xmldb_file->getStructure();
if ($tables = array_reverse($structure->getTables())) {
foreach ($tables as $table) {
// for MySQL, skip dropping indices and keys
// as they will be dropped when the table is dropped
if (!is_mysql() && ($indexes = $table->getIndexes())) {
foreach ($indexes as $index) {
if ($index->getName() == 'usernameuk' && is_postgres()) {
// this is a giant hack, but adodb cannot handle resolving
// the column for indexes that include lower() or something similar
// and i can't find a nice way to do it.
execute_sql('DROP INDEX {usr_use_uix}');
continue;
}
drop_index($table, $index);
}
}
if (!is_mysql() && ($keys = $table->getKeys())) {
$sortkeys = array();
foreach ($keys as $key) {
$sortkeys[] = $key->type;
}
array_multisort($sortkeys, SORT_DESC, $keys);
foreach ($keys as $key) {
if (!is_postgres() && $key->type != XMLDB_KEY_FOREIGN && $key->type != XMLDB_KEY_FOREIGN_UNIQUE) {
// Skip keys for MySQL because these will be
// dropped when the table is dropped
continue;
}
drop_key($table, $key);
}
}
drop_table($table);
}
}
return true;
}
示例7: xmldb_local_upgrade
function xmldb_local_upgrade($oldversion)
{
global $CFG, $db;
$result = true;
$reassigncaps = false;
$resetcustomroles = false;
$resetstickyblocks = false;
// learning path approval status changes
if ($result && $oldversion < 2008091803) {
// fields added to the course table
$table = new XMLDBTable('course');
$field = new XMLDBField('approval_status_id');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, null, null, null, null, null, null);
//function setAttributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
if (!field_exists($table, $field)) {
/// Launch add field shortname
$result = $result && add_field($table, $field);
}
}
if ($oldversion < 2008092100) {
// create the roles we need
$roles = array('superadmin' => array('name' => 'Super Admin', 'description' => 'The highest level site administrator', 'legacy' => 'admin'), 'headteacher' => array('name' => 'Head Teacher', 'description' => 'Oversees the professional development of the teachers at his/her school and other schools that s/he has been assigned to cover.'), 'headeditor' => array('name' => 'Head Editor', 'description' => 'Approves Learning Plans'), 'seniorteacher' => array('name' => 'Senior Teacher', 'description' => 'Has already achieved Participating Teacher and Master Teacher certification and is now pursuing Senior Teacher certification.'), 'masterteacher' => array('name' => 'Master Teacher', 'description' => 'Has already achieved Participating Teacher certification and is now pursuing Master Teacher certification. Is assigned to an Senior Teacher.'), 'participatingteacher' => array('name' => 'Participating Teacher', 'description' => 'Pursuing Participating Teacher certification. Is assigned to an Master Teacher.'), 'translator' => array('name' => 'Translator', 'description' => 'Localizes User Interface'));
foreach ($roles as $shortname => $roledata) {
if (!array_key_exists('legacy', $roledata)) {
$roledata['legacy'] = '';
}
$roles[$shortname]['id'] = create_role($roledata['name'], $shortname, $roledata['description'], $roledata['legacy']);
}
// boostrap superadmin to the same as admin
$admin = get_record('role', 'shortname', 'admin');
role_cap_duplicate($admin, $roles['superadmin']['id']);
}
// try to start over!!!
if ($result && $oldversion < 2008092400) {
$table = new XMLDBTable('course_status_history');
if (table_exists($table)) {
drop_table($table);
}
// fields added to the course table
$table = new XMLDBTable('course');
$field = new XMLDBField('approval_status_id');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, null, null, null, null, null, null);
/// Launch add field approval_status_id
if (!field_exists($table, $field)) {
$result = $result && add_field($table, $field);
}
/// Define table mdl_course_approval_status_history to be created
$table = new XMLDBTable('course_status_history');
/// Adding fields to table mdl_course_approval_status
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('timestamp', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('approval_status_id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('reason', XMLDB_TYPE_TEXT, '1000', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && create_table($table);
}
if ($oldversion < 2008092401) {
$roles = get_records_select('role', "shortname IN ('headteacher', 'headeditor', 'seniorteacher', 'masterteacher', 'participatingteacher', 'translator')");
set_config('messageenabledroles', implode(',', array_keys($roles)));
}
if ($oldversion < 2008092500) {
// add course classification stuff
$table = new XMLDBTable('classification_type');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL);
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL, false, true, array('filter', 'topcategory', 'secondcategory'), 'filter');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && create_table($table);
$table = new XMLDBTable('classification_value');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('type', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('value', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && create_table($table);
$table = new XMLDBTable('course_classification');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('value', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && create_table($table);
}
if ($oldversion < 2008092501) {
// bootstrap out classification system based on the TAO website.
$types = array(array('name' => 'Teaching strategies', 'type' => 'filter', 'values' => array('Connected Model', 'Constructivist Model', 'Integrated Model', 'Nested Model', 'Networked/Extended Model', 'Sequenced Model', 'Shared Model')), array('name' => 'Teaching methods', 'type' => 'filter', 'values' => array('Action-Oriented Learning', 'Active video work', 'Ball Bearings', 'Case Study', 'Creative writing', 'Discovery of learning', 'Excursion', 'Experiment', 'Free work', 'Group Puzzle', 'Learning Circle', 'Learning through teaching', 'Letter method', 'Mind mapping', 'Portfolio', 'Project Work', 'SOL method', 'Station Work', 'Traffic Lights', 'Using Tools and Resources', 'Web quest', 'Weekly Plan', 'Workshop', 'Other')), array('name' => 'Learning styles', 'type' => 'filter', 'values' => array('Visual/spatial', 'Verbal/linguistic', 'Logical/mathematical', 'Musical/rhythmic', 'Bodily/kinaesthetic', 'Interpersonal/social', 'Intrapersonal/introspective', 'Communication', 'Information', 'Simulation', 'Presentation', 'Production', 'Visualisation')), array('name' => 'Key Stages', 'type' => 'topcategory', 'values' => array('1 and 2', '3 and 4')), array('name' => 'Subject', 'type' => 'secondcategory', 'values' => array('English', 'Mathematics', 'Science', 'Design and Technology', 'ICT', 'History', 'Geography', 'Art and Design', 'Music', 'Physical Education')));
foreach ($types as $t) {
$values = $t['values'];
$newid = insert_record('classification_type', (object) $t);
foreach ($values as $v) {
insert_record('classification_value', (object) array('type' => $newid, 'value' => $v));
}
}
}
if ($result && $oldversion < 2008100703) {
// change course status values - seemingly have to drop and recreate the table to reset the serial with xmldb
$table = new XMLDBTable('course_approval_status');
if (table_exists($table)) {
drop_table($table);
}
//.........这里部分代码省略.........
示例8: notify
notify("Error occurred while deleting the {$strblockname} record from blocks table");
}
// Then the tables themselves
if ($tables = $db->Metatables()) {
$prefix = $CFG->prefix . $block->name;
$prefix2 = $CFG->prefix . 'block_' . $block->name;
foreach ($tables as $table) {
if (strpos($table, $prefix) === 0 || strpos($table, $prefix2) === 0) {
/// If the match has been due to the 1st condition, debug to developers
if (strpos($table, $prefix) === 0) {
debugging('This block has some wrongly named tables. See Moodle Docs coding guidelines (and MDL-6786)', DEBUG_DEVELOPER);
}
/// Strip prefix from $table
$table = preg_replace("/^{$CFG->prefix}/", '', $table);
$xmldb_table = new XMLDBTable($table);
if (!drop_table($xmldb_table, true, false)) {
notify("ERROR: while trying to drop table {$table}");
}
}
}
}
// Delete the capabilities that were defined by this block
capabilities_cleanup('block/' . $block->name);
$a->block = $strblockname;
$a->directory = $CFG->dirroot . '/blocks/' . $block->name;
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
}
}
/// Main display starts here
/// Get and sort the existing blocks
if (false === ($blocks = get_records('block'))) {
示例9: xmldb_sloodle_upgrade
function xmldb_sloodle_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
// Note: any upgrade to Sloodle 0.3 is a major process, due to the huge change of architecture.
// As such, the only data worth preserving is the avatar table ('sloodle_users').
// All other tables will be dropped and re-inserted.
// Is this an upgrade from pre-0.3?
if ($result && $oldversion < 2008052800) {
// Drop all other tables
echo "Dropping old tables<br/>";
// (We can ignore failed drops)
/// Drop 'sloodle' table
$table = new XMLDBTable('sloodle');
drop_table($table);
/// Drop 'sloodle_config' table
$table = new XMLDBTable('sloodle_config');
drop_table($table);
/// Drop 'sloodle_active_object' table
$table = new XMLDBTable('sloodle_active_object');
drop_table($table);
/// Drop 'sloodle_classroom_setup_profile' table
$table = new XMLDBTable('sloodle_classroom_setup_profile');
drop_table($table);
/// Drop 'sloodle_classroom_setup_profile_entry' table
$table = new XMLDBTable('sloodle_classroom_setup_profile_entry');
drop_table($table);
// Insert all the new tables
echo "Inserting new tables...<br/>";
/// Insert 'sloodle' table
echo " - sloodle<br/>";
$table = new XMLDBTable('sloodle');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('intro', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
$result = $result && create_table($table);
if (!$result) {
echo "error<br/>";
}
/// Insert 'sloodle_controller' table
echo " - sloodle_controller<br/>";
$table = new XMLDBTable('sloodle_controller');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('sloodleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('enabled', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('password', XMLDB_TYPE_CHAR, '9', null, null, null, null, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('sloodleid', XMLDB_INDEX_UNIQUE, array('sloodleid'));
$result = $result && create_table($table);
if (!$result) {
echo "error<br/>";
}
/// Insert 'sloodle_distributor' table
echo " - sloodle_distributor<br/>";
$table = new XMLDBTable('sloodle_distributor');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('sloodleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('channel', XMLDB_TYPE_CHAR, '36', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('timeupdated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && create_table($table);
if (!$result) {
echo "error<br/>";
}
/// Insert 'sloodle_distributor_entry' table
echo " - sloodle_distributor_entry<br/>";
$table = new XMLDBTable('sloodle_distributor_entry');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('distributorid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && create_table($table);
if (!$result) {
echo "error<br/>";
}
/// Insert 'sloodle_course' table
echo " - sloodle_course<br/>";
$table = new XMLDBTable('sloodle_course');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('autoreg', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('autoenrol', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('loginzonepos', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('loginzonesize', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('loginzoneregion', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('loginzoneupdated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
$result = $result && create_table($table);
if (!$result) {
echo "error<br/>";
}
/// Insert 'sloodle_pending_avatars' table
echo " - sloodle_pending_avatar<br/>";
//.........这里部分代码省略.........
示例10: upgrade_18_groups
/**
* Drop, add fields and rename tables for groups upgrade from 1.8.*
* @param XMLDBTable $table 'groups_groupings' table object.
*/
function upgrade_18_groups()
{
global $CFG, $db;
$result = upgrade_18_groups_drop_keys_indexes();
/// Delete not used columns
$fields_r = array('viewowngroup', 'viewallgroupsmembers', 'viewallgroupsactivities', 'teachersgroupmark', 'teachersgroupview', 'teachersoverride', 'teacherdeletable');
foreach ($fields_r as $fname) {
$table = new XMLDBTable('groups_groupings');
$field = new XMLDBField($fname);
if (field_exists($table, $field)) {
$result = $result && drop_field($table, $field);
}
}
/// Rename 'groups_groupings' to 'groupings'
$table = new XMLDBTable('groups_groupings');
$result = $result && rename_table($table, 'groupings');
/// Add columns/key 'courseid', exclusivegroups, maxgroupsize, timemodified.
$table = new XMLDBTable('groupings');
$field = new XMLDBField('courseid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$result = $result && add_field($table, $field);
$table = new XMLDBTable('groupings');
$key = new XMLDBKey('courseid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
$result = $result && add_key($table, $key);
$table = new XMLDBTable('groupings');
$field = new XMLDBField('configdata');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'description');
$result = $result && add_field($table, $field);
$table = new XMLDBTable('groupings');
$field = new XMLDBField('timemodified');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timecreated');
$result = $result && add_field($table, $field);
//==================
/// Add columns/key 'courseid' into groups table
$table = new XMLDBTable('groups');
$field = new XMLDBField('courseid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$result = $result && add_field($table, $field);
$table = new XMLDBTable('groups');
$key = new XMLDBKey('courseid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
$result = $result && add_key($table, $key);
/// Changing nullability of field enrolmentkey on table groups to null
$table = new XMLDBTable('groups');
$field = new XMLDBField('enrolmentkey');
$field->setAttributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, null, null, 'description');
$result = $result && change_field_notnull($table, $field);
//==================
/// Now, rename 'groups_groupings_groups' to 'groupings_groups' and add keys
$table = new XMLDBTable('groups_groupings_groups');
$result = $result && rename_table($table, 'groupings_groups');
$table = new XMLDBTable('groupings_groups');
$key = new XMLDBKey('groupingid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groupings', array('id'));
$result = $result && add_key($table, $key);
$table = new XMLDBTable('groupings_groups');
$key = new XMLDBKey('groupid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
$result = $result && add_key($table, $key);
///=================
/// Transfer courseid from 'mdl_groups_courses_groups' to 'mdl_groups'.
if ($result) {
$sql = "UPDATE {$CFG->prefix}groups\n SET courseid = (\n SELECT MAX(courseid)\n FROM {$CFG->prefix}groups_courses_groups gcg\n WHERE gcg.groupid = {$CFG->prefix}groups.id)";
execute_sql($sql);
}
/// Transfer courseid from 'groups_courses_groupings' to 'mdl_groupings'.
if ($result) {
$sql = "UPDATE {$CFG->prefix}groupings\n SET courseid = (\n SELECT MAX(courseid)\n FROM {$CFG->prefix}groups_courses_groupings gcg\n WHERE gcg.groupingid = {$CFG->prefix}groupings.id)";
execute_sql($sql);
}
/// Drop the old tables
if ($result) {
drop_table(new XMLDBTable('groups_courses_groups'));
drop_table(new XMLDBTable('groups_courses_groupings'));
drop_table(new XMLDBTable('groups_temp'));
drop_table(new XMLDBTable('groups_members_temp'));
unset_config('group_version');
}
return $result;
}
示例11: uninstall
public static function uninstall($oldversion, $db)
{
// drop database tables
$tables = self::getDbTables();
foreach ($tables as $table) {
drop_table($table);
}
// drop global settings
unset_config('globalmessageenable');
unset_config('globalmessagedisableforadminrole');
unset_config('globalmessagedisableforadminpage');
return true;
}
示例12: drop_plugin_tables
/**
* Delete all plugin tables
* @name string name of plugin, used as table prefix
* @file string path to install.xml file
* @feedback boolean
*/
function drop_plugin_tables($name, $file, $feedback = true)
{
global $CFG, $db;
// first try normal delete
if (delete_tables_from_xmldb_file($file, $feedback)) {
return true;
}
// then try to find all tables that start with name and are not in any xml file
$used_tables = get_used_table_names();
$tables = $db->MetaTables();
/// Iterate over, fixing id fields as necessary
foreach ($tables as $table) {
if (strlen($CFG->prefix)) {
if (strpos($table, $CFG->prefix) !== 0) {
continue;
}
$table = substr($table, strlen($CFG->prefix));
}
$table = strtolower($table);
if (strpos($table, $name) !== 0) {
continue;
}
if (in_array($table, $used_tables)) {
continue;
}
// found orphan table --> delete it
$table = new XMLDBTable($table);
if (table_exists($table)) {
drop_table($table, true, $feedback);
}
}
return true;
}
示例13: xmldb_main_upgrade
function xmldb_main_upgrade($oldversion = 0)
{
global $CFG, $THEME, $USER, $SITE, $db;
$result = true;
if ($result && $oldversion < 2006100401) {
/// Only for those tracking Moodle 1.7 dev, others will have these dropped in moodle_install_roles()
if (!empty($CFG->rolesactive)) {
drop_table(new XMLDBTable('user_students'));
drop_table(new XMLDBTable('user_teachers'));
drop_table(new XMLDBTable('user_coursecreators'));
drop_table(new XMLDBTable('user_admins'));
}
upgrade_main_savepoint($result, 2006100401);
}
if ($result && $oldversion < 2006100601) {
/// Disable the exercise module because it's unmaintained
if ($module = get_record('modules', 'name', 'exercise')) {
if ($module->visible) {
// Hide/disable the module entry
set_field('modules', 'visible', '0', 'id', $module->id);
// Save existing visible state for all activities
set_field('course_modules', 'visibleold', '1', 'visible', '1', 'module', $module->id);
set_field('course_modules', 'visibleold', '0', 'visible', '0', 'module', $module->id);
// Hide all activities
set_field('course_modules', 'visible', '0', 'module', $module->id);
//require_once($CFG->dirroot.'/course/lib.php');
//rebuild_course_cache(); // Rebuld cache for all modules because they might have changed
}
}
upgrade_main_savepoint($result, 2006100601);
}
if ($result && $oldversion < 2006101001) {
/// Disable the LAMS module by default (if it is installed)
if (count_records('modules', 'name', 'lams') && !count_records('lams')) {
set_field('modules', 'visible', 0, 'name', 'lams');
// Disable it by default
}
upgrade_main_savepoint($result, 2006101001);
}
if ($result && $oldversion < 2006102600) {
/// Define fields to be added to user_info_field
$table = new XMLDBTable('user_info_field');
$field = new XMLDBField('description');
$field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'categoryid');
$field1 = new XMLDBField('param1');
$field1->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'defaultdata');
$field2 = new XMLDBField('param2');
$field2->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param1');
$field3 = new XMLDBField('param3');
$field3->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param2');
$field4 = new XMLDBField('param4');
$field4->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param3');
$field5 = new XMLDBField('param5');
$field5->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param4');
/// Launch add fields
$result = $result && add_field($table, $field);
$result = $result && add_field($table, $field1);
$result = $result && add_field($table, $field2);
$result = $result && add_field($table, $field3);
$result = $result && add_field($table, $field4);
$result = $result && add_field($table, $field5);
upgrade_main_savepoint($result, 2006102600);
}
if ($result && $oldversion < 2006112000) {
/// Define field attachment to be added to post
$table = new XMLDBTable('post');
$field = new XMLDBField('attachment');
$field->setAttributes(XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null, 'format');
/// Launch add field attachment
$result = $result && add_field($table, $field);
upgrade_main_savepoint($result, 2006112000);
}
if ($result && $oldversion < 2006112200) {
/// Define field imagealt to be added to user
$table = new XMLDBTable('user');
$field = new XMLDBField('imagealt');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null, 'trustbitmask');
/// Launch add field imagealt
$result = $result && add_field($table, $field);
$table = new XMLDBTable('user');
$field = new XMLDBField('screenreader');
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0', 'imagealt');
/// Launch add field screenreader
$result = $result && add_field($table, $field);
upgrade_main_savepoint($result, 2006112200);
}
if ($result && $oldversion < 2006120300) {
/// Delete guest course section settings
// following code can be executed repeatedly, such as when upgrading from 1.7.x - it is ok
if ($guest = get_record('user', 'username', 'guest')) {
execute_sql("DELETE FROM {$CFG->prefix}course_display where userid={$guest->id}", true);
}
upgrade_main_savepoint($result, 2006120300);
}
if ($result && $oldversion < 2006120400) {
/// Remove secureforms config setting
execute_sql("DELETE FROM {$CFG->prefix}config where name='secureforms'", true);
upgrade_main_savepoint($result, 2006120400);
}
if (!empty($CFG->rolesactive) && $oldversion < 2006120700) {
//.........这里部分代码省略.........
示例14: xmldb_core_upgrade
//.........这里部分代码省略.........
$cron->callfunction = 'auth_handle_institution_expiries';
$cron->minute = '5';
$cron->hour = '9';
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
}
}
if ($oldversion < 2009031800) {
// Files can only attach blogpost artefacts, but we would like to be able to attach them
// to other stuff. Rename the existing attachment table artefact_blog_blogpost_file to
// artefact_file_attachment so we don't end up with many tables doing the same thing.
execute_sql("ALTER TABLE {artefact_blog_blogpost_file} RENAME TO {artefact_attachment}");
if (is_postgres()) {
// Ensure all of the indexes and constraints are renamed
execute_sql("\n ALTER TABLE {artefact_attachment} RENAME blogpost TO artefact;\n ALTER TABLE {artefact_attachment} RENAME file TO attachment;\n\n ALTER INDEX {arteblogblogfile_blofil_pk} RENAME TO {arteatta_artatt_pk};\n ALTER INDEX {arteblogblogfile_blo_ix} RENAME TO {arteatta_art_ix};\n ALTER INDEX {arteblogblogfile_fil_ix} RENAME TO {arteatta_att_ix};\n\n ALTER TABLE {artefact_attachment} DROP CONSTRAINT {arteblogblogfile_blo_fk};\n ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_art_fk} FOREIGN KEY (artefact) REFERENCES {artefact}(id);\n\n ALTER TABLE {artefact_attachment} DROP CONSTRAINT {arteblogblogfile_fil_fk};\n ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_att_fk} FOREIGN KEY (attachment) REFERENCES {artefact}(id);\n ");
} else {
if (is_mysql()) {
execute_sql("ALTER TABLE {artefact_attachment} DROP FOREIGN KEY {arteblogblogfile_blo_fk}");
execute_sql("ALTER TABLE {artefact_attachment} DROP INDEX {arteblogblogfile_blo_ix}");
execute_sql("ALTER TABLE {artefact_attachment} CHANGE blogpost artefact BIGINT(10) DEFAULT NULL");
execute_sql("ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_art_fk} FOREIGN KEY {arteatta_art_ix} (artefact) REFERENCES {artefact}(id)");
execute_sql("ALTER TABLE {artefact_attachment} DROP FOREIGN KEY {arteblogblogfile_fil_fk}");
execute_sql("ALTER TABLE {artefact_attachment} DROP INDEX {arteblogblogfile_fil_ix}");
execute_sql("ALTER TABLE {artefact_attachment} CHANGE file attachment BIGINT(10) DEFAULT NULL");
execute_sql("ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_att_fk} FOREIGN KEY {arteatta_att_ix} (attachment) REFERENCES {artefact}(id)");
}
}
// Drop the _pending table. From now on files uploaded as attachments will become artefacts
// straight away. Hopefully changes to the upload/file browser form will make it clear to
// the user that these attachments sit in his/her files area as soon as they are uploaded.
$table = new XMLDBTable('artefact_blog_blogpost_file_pending');
drop_table($table);
}
if ($oldversion < 2009040900) {
// The view access page has been putting the string 'null' in as a group role in IE.
set_field('view_access_group', 'role', null, 'role', 'null');
}
if ($oldversion < 2009040901) {
$table = new XMLDBTable('import_installed');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('version', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('release', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('active', XMLDB_TYPE_INTEGER, 1, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 1);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('name'));
create_table($table);
$table = new XMLDBTable('import_cron');
$table->addFieldInfo('plugin', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('callfunction', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('minute', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('hour', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('day', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('dayofweek', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('month', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('nextrun', XMLDB_TYPE_DATETIME, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('plugin', 'callfunction'));
$table->addKeyInfo('pluginfk', XMLDB_KEY_FOREIGN, array('plugin'), 'import_installed', array('name'));
create_table($table);
$table = new XMLDBTable('import_config');
$table->addFieldInfo('plugin', XMLDB_TYPE_CHAR, 100, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('field', XMLDB_TYPE_CHAR, 100, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('plugin', 'field'));
$table->addKeyInfo('pluginfk', XMLDB_KEY_FOREIGN, array('plugin'), 'import_installed', array('name'));
create_table($table);
示例15: database_creation
/**
* Step 3 of installation - Creates database tables
*/
function database_creation()
{
global $lang;
// delete existing cache
delete_files(CACHE . 'db_cache');
delete_files(CACHE . 'css_js_cache');
delete_files(CACHE . 'rss_cache');
echo html_header();
// Step title
echo "<h2>" . $lang['install_step3'] . "</h2>\n";
// delete *all* plugin tables:
$plugin_tables = list_plugin_tables();
foreach ($plugin_tables as $pt) {
drop_table($pt);
// table name
}
//create tables
$tables = array('blocked', 'categories', 'comments', 'commentvotes', 'friends', 'messaging', 'miscdata', 'plugins', 'pluginhooks', 'pluginsettings', 'posts', 'postmeta', 'postvotes', 'settings', 'tags', 'tempdata', 'tokens', 'users', 'usermeta', 'useractivity', 'widgets');
foreach ($tables as $table_name) {
create_table($table_name);
}
// Step content
echo "<div class='install_content'>" . $lang['install_step3_success'] . "</div>\n";
// Previous/Next buttons
echo "<div class='back'><a href='install.php?step=2'>" . $lang['install_back'] . "</a></div>\n";
echo "<div class='next'><a href='install.php?step=4'>" . $lang['install_next'] . "</a></div>\n";
echo html_footer();
}