当前位置: 首页>>代码示例>>PHP>>正文


PHP xmldb_table::add_index方法代码示例

本文整理汇总了PHP中xmldb_table::add_index方法的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_table::add_index方法的具体用法?PHP xmldb_table::add_index怎么用?PHP xmldb_table::add_index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmldb_table的用法示例。


在下文中一共展示了xmldb_table::add_index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmldb_studyplan_upgrade

/**
 * Execute studyplan upgrade from the given old version
 *
 * @param int $oldversion
 * @return bool
 */
function xmldb_studyplan_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    // loads ddl manager and xmldb classes
    if ($oldversion < 2014071400) {
        // Change field 'name' column to default null
        $table = new xmldb_table('studyplan');
        $field = new xmldb_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'quiz');
        // apply the change if the field is here to fix
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_type($table, $field);
        }
        upgrade_mod_savepoint(true, 2014071400, 'studyplan');
    }
    if ($oldversion < 2014080700) {
        // Create the studyplan_progress table
        if (!$dbman->table_exists('studyplan_progress')) {
            $table = new xmldb_table('studyplan_progress');
            $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
            $table->add_field('studyplan', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id');
            $table->add_field('user', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'studyplan');
            $table->add_field('percent', XMLDB_TYPE_NUMBER, '10,5', null, XMLDB_NOTNULL, null, '0', 'user');
            $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'percent');
            $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timecreated');
            $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
            $table->add_index('studyplan', XMLDB_INDEX_NOTUNIQUE, array('studyplan'));
            $table->add_index('user', XMLDB_INDEX_NOTUNIQUE, array('user'));
            $dbman->create_table($table);
        }
        upgrade_mod_savepoint(true, 2014080700, 'studyplan');
    }
    return true;
}
开发者ID:bcvincent,项目名称:studyplan,代码行数:40,代码来源:upgrade.php

示例2: xmldb_tool_mergeusers_upgrade

/**
 * Take actions on upgrading mergeusers tool.
 * @package tool_mergeusers
 * @global moodle_database $DB
 * @param int $oldversion old plugin version.
 * @return boolean true when success, false on error.
 */
function xmldb_tool_mergeusers_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013112912) {
        // Define table tool_mergeusers to be created
        $table = new xmldb_table('tool_mergeusers');
        // Adding fields to table tool_mergeusers
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('touserid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('fromuserid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('success', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null);
        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('log', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
        // Adding keys to table tool_mergeusers
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table tool_mergeusers
        $table->add_index('mdl_toolmerg_tou_ix', XMLDB_INDEX_NOTUNIQUE, array('touserid'));
        $table->add_index('mdl_toolmerg_fru_ix', XMLDB_INDEX_NOTUNIQUE, array('fromuserid'));
        $table->add_index('mdl_toolmerg_suc_ix', XMLDB_INDEX_NOTUNIQUE, array('success'));
        $table->add_index('mdl_toolmerg_tfs_ix', XMLDB_INDEX_NOTUNIQUE, array('touserid', 'fromuserid', 'success'));
        // Conditionally launch create table for tool_mergeusersr
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // mergeusers savepoint reached
        upgrade_plugin_savepoint(true, 2013112912, 'tool', 'mergeusers');
    }
    return true;
}
开发者ID:advancingdesign,项目名称:moodle-tool_mergeusers,代码行数:37,代码来源:upgrade.php

示例3: setUp

 public function setUp()
 {
     global $CFG, $DB, $UNITTEST;
     if (isset($UNITTEST->func_test_db)) {
         $this->tdb = $UNITTEST->func_test_db;
     } else {
         $this->tdb = $DB;
     }
     unset($CFG->xmldbreconstructprevnext);
     // remove this unhack ;-)
     $dbman = $this->tdb->get_manager();
     $table = new xmldb_table('test_table0');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'general');
     $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null);
     $table->add_field('intro', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
     $table->add_field('logo', XMLDB_TYPE_BINARY, 'big', null, XMLDB_NOTNULL, null);
     $table->add_field('assessed', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('assesstimestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('assesstimefinish', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('scale', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('maxbytes', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('forcesubscribe', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('trackingtype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
     $table->add_field('rsstype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('rssarticles', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('grade', XMLDB_TYPE_NUMBER, '20,0', XMLDB_UNSIGNED, null, null, null);
     $table->add_field('percent', XMLDB_TYPE_NUMBER, '5,2', null, null, null, null);
     $table->add_field('warnafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('blockafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('blockperiod', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('type-name', XMLDB_KEY_UNIQUE, array('type', 'name'));
     $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
     $table->add_index('rsstype', XMLDB_INDEX_UNIQUE, array('rsstype'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     // Second, smaller table
     $table = new xmldb_table('test_table1');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('name', XMLDB_TYPE_CHAR, '30', null, null, null, 'Moodle');
     $table->add_field('secondname', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null);
     $table->add_field('intro', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null);
     $table->add_field('avatar', XMLDB_TYPE_BINARY, 'medium', null, null, null, null);
     $table->add_field('grade', XMLDB_TYPE_NUMBER, '20,10', null, null, null);
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     // make sure no tables are present!
     $this->tearDown();
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:54,代码来源:testddl.php

示例4: xmldb_chat_upgrade

function xmldb_chat_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    $result = true;
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2008072400) {
        /// Define table chat_messages_current to be created
        $table = new xmldb_table('chat_messages_current');
        /// Adding fields to table chat_messages_current
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('chatid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('system', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        $table->add_field('message', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
        $table->add_field('timestamp', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        /// Adding keys to table chat_messages_current
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('chatid', XMLDB_KEY_FOREIGN, array('chatid'), 'chat', array('id'));
        /// Adding indexes to table chat_messages_current
        $table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
        $table->add_index('groupid', XMLDB_INDEX_NOTUNIQUE, array('groupid'));
        $table->add_index('timestamp-chatid', XMLDB_INDEX_NOTUNIQUE, array('timestamp', 'chatid'));
        /// create table for chat_messages_current
        $dbman->create_table($table);
        /// chat savepoint reached
        upgrade_mod_savepoint($result, 2008072400, 'chat');
    }
    if ($result && $oldversion < 2009010600) {
        /// Changing precision of field ip on table chat_users to (45)
        $table = new xmldb_table('chat_users');
        $field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'version');
        /// Launch change of precision for field ip
        $dbman->change_field_precision($table, $field);
        /// chat savepoint reached
        upgrade_mod_savepoint($result, 2009010600, 'chat');
    }
    if ($result && $oldversion < 2009042000) {
        /// Define field introformat to be added to chat
        $table = new xmldb_table('chat');
        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
        /// Launch add field introformat
        $dbman->add_field($table, $field);
        /// chat savepoint reached
        upgrade_mod_savepoint($result, 2009042000, 'chat');
    }
    return $result;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:49,代码来源:upgrade.php

示例5: xmldb_local_contextadmin_upgrade

/**
 * @package eclass-local-contextadmin
 * @author joshstagg
 * @copyright Josh Stagg
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_local_contextadmin_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013100813) {
        // Adding fields to table.
        $table = new xmldb_table('cat_role_names');
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
        $table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
        $table->add_field('catid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'roleid');
        $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'catid');
        // Add keys to table.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('roleid', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id'));
        $table->add_key('catid', XMLDB_KEY_FOREIGN, array('catid'), 'course_categories', array('id'));
        // Add indices.
        $table->add_index('roleid-catid', XMLDB_INDEX_UNIQUE, array('roleid', 'catid'));
        // Conditionally launch add table.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
            // Main savepoint reached.
            upgrade_plugin_savepoint(true, 2013100813, 'local', 'contextadmin');
        }
    }
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:31,代码来源:upgrade.php

示例6: xmldb_message_popup_upgrade

/**
 * Upgrade code for the popup message processor
 *
 * @param int $oldversion The version that we are upgrading from
 */
function xmldb_message_popup_upgrade($oldversion)
{
    global $CFG, $DB;
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.
    $dbman = $DB->get_manager();
    if ($oldversion < 2016052309) {
        // Define table message_popup to be created.
        $table = new xmldb_table('message_popup');
        // Adding fields to table message_popup.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('messageid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('isread', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
        // Adding keys to table message_popup.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table message_popup.
        $table->add_index('messageid-isread', XMLDB_INDEX_UNIQUE, array('messageid', 'isread'));
        // Conditionally launch create table for message_popup.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Popup savepoint reached.
        upgrade_plugin_savepoint(true, 2016052309, 'message', 'popup');
    }
    return true;
}
开发者ID:dg711,项目名称:moodle,代码行数:37,代码来源:upgrade.php

示例7: xmldb_block_recent_activity_upgrade

/**
 * Upgrade code for the recent activity block.
 *
 * @global moodle_database $DB
 * @param int $oldversion
 * @param object $block
 */
function xmldb_block_recent_activity_upgrade($oldversion, $block)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // loads ddl manager and xmldb classes
    if ($oldversion < 2014012000) {
        // Define table block_recent_activity to be created.
        $table = new xmldb_table('block_recent_activity');
        // Adding fields to table block_recent_activity.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('cmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('action', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
        $table->add_field('modname', XMLDB_TYPE_CHAR, '20', null, null, null, null);
        // Adding keys to table block_recent_activity.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table block_recent_activity.
        $table->add_index('coursetime', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'timecreated'));
        // Conditionally launch create table for block_recent_activity.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
            // Insert dummy log record for each existing course to notify that their logs need to be migrated.
            $DB->execute('INSERT INTO {block_recent_activity} (timecreated, userid, courseid, cmid, action) ' . 'SELECT ?, 0, id, 0, 3 FROM {course}', array(time()));
        }
        // Recent_activity savepoint reached.
        upgrade_block_savepoint(true, 2014012000, 'recent_activity');
    }
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:40,代码来源:upgrade.php

示例8: xmldb_logstore_xapi_upgrade

/**
 * xAPI log store upgrade.
 *
 * @package    logstore_xapi
 * @copyright  2015 Michael Aherne
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_logstore_xapi_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2015081001) {
        // Define table logstore_xapi_log to be created.
        $table = new xmldb_table('logstore_xapi_log');
        // Adding fields to table logstore_xapi_log.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('eventname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
        $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
        $table->add_field('action', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
        $table->add_field('target', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
        $table->add_field('objecttable', XMLDB_TYPE_CHAR, '50', null, null, null, null);
        $table->add_field('objectid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        $table->add_field('crud', XMLDB_TYPE_CHAR, '1', null, XMLDB_NOTNULL, null, null);
        $table->add_field('edulevel', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
        $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('contextlevel', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('contextinstanceid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        $table->add_field('relateduserid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        $table->add_field('anonymous', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('other', XMLDB_TYPE_TEXT, null, null, null, null, null);
        $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('origin', XMLDB_TYPE_CHAR, '10', null, null, null, null);
        $table->add_field('ip', XMLDB_TYPE_CHAR, '45', null, null, null, null);
        $table->add_field('realuserid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        // Adding keys to table logstore_xapi_log.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table logstore_xapi_log.
        $table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
        $table->add_index('course-time', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'anonymous', 'timecreated'));
        $table->add_index('user-module', XMLDB_INDEX_NOTUNIQUE, array('userid', 'contextlevel', 'contextinstanceid', 'crud', 'edulevel', 'timecreated'));
        // Conditionally launch create table for logstore_xapi_log.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Xapi savepoint reached.
        upgrade_plugin_savepoint(true, 2015081001, 'logstore', 'xapi');
    }
    return true;
}
开发者ID:ninelanterns,项目名称:moodle-logstore_xapi,代码行数:51,代码来源:upgrade.php

示例9: xmldb_report_ncccscensus_upgrade

/**
 * Upgrade code containing changes to the plugin data table.
 *
 * @package    report_ncccscensus
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @copyright  (C) 2014 Remote Learner.net Inc http://www.remote-learner.net
 */
function xmldb_report_ncccscensus_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014073101) {
        // Define table ncccscensus_reports to be created.
        $table = new xmldb_table('ncccscensus_reports');
        // Adding fields to table ncccscensus_reports.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('batchid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('status', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('filename', XMLDB_TYPE_CHAR, '255', null, null, null, '0');
        $table->add_field('fullfilename', XMLDB_TYPE_CHAR, '255', null, null, null, '0');
        $table->add_field('starttime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('reportstartdate', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('reportenddate', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        // Adding keys to table ncccscensus_reports.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table ncccscensus_reports.
        $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
        // Conditionally launch create table for ncccscensus_reports.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Define table ncccscensus_batch to be created.
        $table = new xmldb_table('ncccscensus_batch');
        // Adding fields to table ncccscensus_batch.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('status', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('starttime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('zipfile', XMLDB_TYPE_CHAR, '255', null, null, null, '0');
        // Adding keys to table ncccscensus_batch.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table ncccscensus_batch.
        $table->add_index('status', XMLDB_INDEX_NOTUNIQUE, array('status'));
        // Conditionally launch create table for ncccscensus_batch.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Ncccscensus savepoint reached.
        upgrade_plugin_savepoint(true, 2014073101, 'report', 'ncccscensus');
    }
    if ($oldversion < 2014073104.01) {
        // Standardize table names, preventing namespace collisions.
        $dbman->rename_table(new xmldb_table('ncccscensus_reports'), 'report_ncccscensus');
        $dbman->rename_table(new xmldb_table('ncccscensus_batch'), 'report_ncccscensus_batch');
        // Ncccscensus savepoint reached.
        upgrade_plugin_savepoint(true, 2014073104.01, 'report', 'ncccscensus');
    }
    return true;
}
开发者ID:cbmegahan,项目名称:report_ncccscensus,代码行数:60,代码来源:upgrade.php

示例10: xmldb_theme_snap_upgrade

/**
 * Theme upgrade
 *
 * @package   theme_snap
 * @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_theme_snap_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014080400) {
        if (get_config('core', 'theme') == 'snap') {
            set_config('deadlinestoggle', 0, 'theme_snap');
            set_config('messagestoggle', 0, 'theme_snap');
        }
        upgrade_plugin_savepoint(true, 2014080400, 'theme', 'snap');
    }
    if ($oldversion < 2014090900) {
        if (get_config('core', 'theme') == 'snap') {
            set_config('coursefootertoggle', 0, 'theme_snap');
        }
        upgrade_plugin_savepoint(true, 2014090900, 'theme', 'snap');
    }
    if ($oldversion < 2014110404) {
        theme_snap_process_site_coverimage();
        upgrade_plugin_savepoint(true, 2014110404, 'theme', 'snap');
    }
    if ($oldversion < 2016042900) {
        // Set default value for showing personal menu on login.
        if (get_config('core', 'theme') == 'snap') {
            set_config('personalmenulogintoggle', 0, 'theme_snap');
        }
        // Snap savepoint reached.
        upgrade_plugin_savepoint(true, 2016042900, 'theme', 'snap');
    }
    if ($oldversion < 2016042904) {
        // Define table theme_snap_course_favorites to be created.
        $table = new xmldb_table('theme_snap_course_favorites');
        // Adding fields to table theme_snap_course_favorites.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('timefavorited', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table theme_snap_course_favorites.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table theme_snap_course_favorites.
        $table->add_index('userid-courseid', XMLDB_INDEX_UNIQUE, array('userid', 'courseid'));
        // Conditionally launch create table for theme_snap_course_favorites.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Snap savepoint reached.
        upgrade_plugin_savepoint(true, 2016042904, 'theme', 'snap');
    }
    return true;
}
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:57,代码来源:upgrade.php

示例11: xmldb_local_saml_site_upgrade

function xmldb_local_saml_site_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    /// loads ddl manager and xmldb classes
    if ($oldversion < 2015111901) {
        // Define table local_saml_site_rules to be created.
        $table = new xmldb_table('local_saml_site_rules');
        // Adding fields to table local_saml_site_rules.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('local_saml_site_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('rule', XMLDB_TYPE_TEXT, null, null, null, null, null);
        $table->add_field('ruletype', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, '1');
        // Adding keys to table local_saml_site_rules.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table local_saml_site_rules.
        $table->add_index('local_saml_site_id', XMLDB_INDEX_NOTUNIQUE, array('local_saml_site_id'));
        // Conditionally launch create table for local_saml_site_rules.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Define field rule to be dropped from local_saml_site.
        $table = new xmldb_table('local_saml_site');
        $field = new xmldb_field('rule');
        // Conditionally launch drop field rule.
        if ($dbman->field_exists($table, $field)) {
            $dbman->drop_field($table, $field);
        }
        $field = new xmldb_field('ruletype');
        // Conditionally launch drop field ruletype.
        if ($dbman->field_exists($table, $field)) {
            $dbman->drop_field($table, $field);
        }
        // Saml_site savepoint reached.
        upgrade_plugin_savepoint(true, 2015111901, 'local', 'saml_site');
    }
    if ($oldversion < 2015122401) {
        // Define field customprofilefield to be added to local_saml_site_rules.
        $table = new xmldb_table('local_saml_site_rules');
        $field = new xmldb_field('customprofilefield', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'ruletype');
        // Conditionally launch add field customprofilefield.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Saml_site savepoint reached.
        upgrade_plugin_savepoint(true, 2015122401, 'local', 'saml_site');
    }
    return true;
}
开发者ID:atlet,项目名称:moodle-local_saml_site,代码行数:49,代码来源:upgrade.php

示例12: xmldb_block_my_enrolled_courses_upgrade

/**
 * Version details
 *
 * @package    block
 * @subpackage block_my_enrolled_courses
 * @copyright  Dualcube (http://dualcube.com)
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_block_my_enrolled_courses_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014102202) {
        $table = new xmldb_table('block_myenrolledcoursesorder');
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('courseorder', XMLDB_TYPE_TEXT, 'long', null, XMLDB_NOTNULL, null, null);
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        upgrade_block_savepoint(true, 2014102202, 'my_enrolled_courses');
    }
    return true;
}
开发者ID:Kemmotar83,项目名称:moodle-block_my_enrolled_courses,代码行数:26,代码来源:upgrade.php

示例13: xmldb_respondusws_upgrade

function xmldb_respondusws_upgrade($oldversion = 0)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013061700) {
        $table = new xmldb_table("respondusws_auth_users");
        $table->add_field("id", XMLDB_TYPE_INTEGER, "10", XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
        $table->add_field("responduswsid", XMLDB_TYPE_INTEGER, "10", XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, "id");
        $table->add_field("userid", XMLDB_TYPE_INTEGER, "10", XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, "responduswsid");
        $table->add_field("authtoken", XMLDB_TYPE_CHAR, "64", null, XMLDB_NOTNULL, null, null, "userid");
        $table->add_field("timeissued", XMLDB_TYPE_INTEGER, "10", XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, "authtoken");
        $table->add_key("primary", XMLDB_KEY_PRIMARY, array("id"));
        $table->add_key("responduswsid_fk", XMLDB_KEY_FOREIGN, array("responduswsid"), "respondusws", array("id"));
        $table->add_key("userid_fk", XMLDB_KEY_FOREIGN_UNIQUE, array("userid"), "user", array("id"));
        $table->add_index("authtoken_ix", XMLDB_INDEX_UNIQUE, array("authtoken"));
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        upgrade_mod_savepoint(true, 2013061700, "respondusws");
    }
    return true;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:22,代码来源:upgrade.php

示例14: xmldb_local_userenrols_upgrade

/**
 * Handle database updates
 *
 * @param   int         $oldversion     The currently recorded version for this mod/plugin
 * @return  boolean
 * @uses $DB
 */
function xmldb_local_userenrols_upgrade($oldversion = 0)
{
    global $DB;
    $dbman = $DB->get_manager();
    $result = true;
    if ($oldversion < 2013052002) {
        try {
            // Use a stable to persist metacourse->group prefs
            $table = new xmldb_table('local_userenrols_metagroup');
            $table->add_field('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
            $table->add_field('course', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null);
            $table->add_field('data', XMLDB_TYPE_TEXT, null, false, XMLDB_NOTNULL, false, null);
            $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
            $table->add_index('course', XMLDB_INDEX_UNIQUE, array('course'));
            if (!$dbman->table_exists($table)) {
                $dbman->create_table($table);
            }
            upgrade_plugin_savepoint(true, 2013052002, 'local', 'userenrols');
        } catch (Exception $exc) {
            $result = false;
        }
    }
    return $result;
}
开发者ID:aj-michael,项目名称:moodle-local_userenrols,代码行数:31,代码来源:upgrade.php

示例15: xmldb_main_upgrade

/**
 * Main upgrade tasks to be executed on Moodle version bump
 *
 * This function is automatically executed after one bump in the Moodle core
 * version is detected. It's in charge of performing the required tasks
 * to raise core from the previous version to the next one.
 *
 * It's a collection of ordered blocks of code, named "upgrade steps",
 * each one performing one isolated (from the rest of steps) task. Usually
 * tasks involve creating new DB objects or performing manipulation of the
 * information for cleanup/fixup purposes.
 *
 * Each upgrade step has a fixed structure, that can be summarised as follows:
 *
 * if ($oldversion < XXXXXXXXXX.XX) {
 *     // Explanation of the update step, linking to issue in the Tracker if necessary
 *     upgrade_set_timeout(XX); // Optional for big tasks
 *     // Code to execute goes here, usually the XMLDB Editor will
 *     // help you here. See {@link http://docs.moodle.org/dev/XMLDB_editor}.
 *     upgrade_main_savepoint(true, XXXXXXXXXX.XX);
 * }
 *
 * All plugins within Moodle (modules, blocks, reports...) support the existence of
 * their own upgrade.php file, using the "Frankenstyle" component name as
 * defined at {@link http://docs.moodle.org/dev/Frankenstyle}, for example:
 *     - {@link xmldb_page_upgrade($oldversion)}. (modules don't require the plugintype ("mod_") to be used.
 *     - {@link xmldb_auth_manual_upgrade($oldversion)}.
 *     - {@link xmldb_workshopform_accumulative_upgrade($oldversion)}.
 *     - ....
 *
 * In order to keep the contents of this file reduced, it's allowed to create some helper
 * functions to be used here in the {@link upgradelib.php} file at the same directory. Note
 * that such a file must be manually included from upgrade.php, and there are some restrictions
 * about what can be used within it.
 *
 * For more information, take a look to the documentation available:
 *     - Data definition API: {@link http://docs.moodle.org/dev/Data_definition_API}
 *     - Upgrade API: {@link http://docs.moodle.org/dev/Upgrade_API}
 *
 * @param int $oldversion
 * @return bool always true
 */
function xmldb_main_upgrade($oldversion)
{
    global $CFG, $USER, $DB, $OUTPUT, $SITE, $COURSE;
    require_once $CFG->libdir . '/db/upgradelib.php';
    // Core Upgrade-related functions
    $dbman = $DB->get_manager();
    // loads ddl manager and xmldb classes
    if ($oldversion < 2011120500) {
        // just in case somebody hacks upgrade scripts or env, we really can not continue
        echo "You need to upgrade to 2.2.x first!\n";
        exit(1);
        // Note this savepoint is 100% unreachable, but needed to pass the upgrade checks
        upgrade_main_savepoint(true, 2011120500);
    }
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2011120500.02) {
        upgrade_set_timeout(60 * 20);
        // This may take a while
        // MDL-28180. Some missing restrictions in certain backup & restore operations
        // were causing incorrect duplicates in the course_completion_aggr_methd table.
        // This upgrade step takes rid of them.
        $sql = 'SELECT course, criteriatype, MIN(id) AS minid
                  FROM {course_completion_aggr_methd}
              GROUP BY course, criteriatype
                HAVING COUNT(*) > 1';
        $duprs = $DB->get_recordset_sql($sql);
        foreach ($duprs as $duprec) {
            // We need to handle NULLs in criteriatype diferently
            if (is_null($duprec->criteriatype)) {
                $where = 'course = ? AND criteriatype IS NULL AND id > ?';
                $params = array($duprec->course, $duprec->minid);
            } else {
                $where = 'course = ? AND criteriatype = ? AND id > ?';
                $params = array($duprec->course, $duprec->criteriatype, $duprec->minid);
            }
            $DB->delete_records_select('course_completion_aggr_methd', $where, $params);
        }
        $duprs->close();
        // Main savepoint reached
        upgrade_main_savepoint(true, 2011120500.02);
    }
    if ($oldversion < 2011120500.03) {
        // Changing precision of field value on table user_preferences to (1333)
        $table = new xmldb_table('user_preferences');
        $field = new xmldb_field('value', XMLDB_TYPE_CHAR, '1333', null, XMLDB_NOTNULL, null, null, 'name');
        // Launch change of precision for field value
        $dbman->change_field_precision($table, $field);
        // Main savepoint reached
        upgrade_main_savepoint(true, 2011120500.03);
    }
    if ($oldversion < 2012020200.03) {
        // Define index rolecontext (not unique) to be added to role_assignments
        $table = new xmldb_table('role_assignments');
        $index = new xmldb_index('rolecontext', XMLDB_INDEX_NOTUNIQUE, array('roleid', 'contextid'));
        // Conditionally launch add index rolecontext
        if (!$dbman->index_exists($table, $index)) {
            $dbman->add_index($table, $index);
//.........这里部分代码省略.........
开发者ID:HuiChangZhai,项目名称:moodle,代码行数:101,代码来源:upgrade.php


注:本文中的xmldb_table::add_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。