• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP xmldb_table类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: xmldb_assignsubmission_onlinepoodll_upgrade

/**
 * Stub for upgrade code
 * @param int $oldversion
 * @return bool
 */
function xmldb_assignsubmission_onlinepoodll_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    //Change table name to satisfy Moodle.org plugin submissions component name v table name check
    //ie it checks(or will) check 1st 28 chars of component name matches table name.
    if ($oldversion < 2012112000) {
        $table = new xmldb_table('assignsubmission_onlinepood');
        if ($dbman->table_exists($table)) {
            $dbman->rename_table($table, 'assignsubmission_onlinepoodl', $continue = true, $feedback = true);
        }
        // online PoodLL savepoint reached
        upgrade_plugin_savepoint(true, 2012112000, 'assignsubmission', 'onlinepoodll');
    }
    //add filename field.
    if ($oldversion < 2013120500) {
        $table = new xmldb_table('assignsubmission_onlinepoodl');
        $table->add_field('filename', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
        // online PoodLL savepoint reached
        upgrade_plugin_savepoint(true, 2013120500, 'assignsubmission', 'onlinepoodll');
    }
    return true;
}
开发者ID:laiello,项目名称:poodll.poodll23,代码行数:32,代码来源:upgrade.php


示例2: xmldb_choicegroup_upgrade

function xmldb_choicegroup_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013070900) {
        if ($oldversion < 2012042500) {
            /// remove the no longer needed choicegroup_answers DB table
            $choicegroup_answers = new xmldb_table('choicegroup_answers');
            $dbman->drop_table($choicegroup_answers);
            /// change the choicegroup_options.text (text) field as choicegroup_options.groupid (int)
            $choicegroup_options = new xmldb_table('choicegroup_options');
            $field_text = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'choicegroupid');
            $field_groupid = new xmldb_field('groupid', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'choicegroupid');
            $dbman->rename_field($choicegroup_options, $field_text, 'groupid');
            $dbman->change_field_type($choicegroup_options, $field_groupid);
        }
        // Define table choicegroup to be created
        $table = new xmldb_table('choicegroup');
        // Adding fields to table choicegroup
        $newField = $table->add_field('multipleenrollmentspossible', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
        $dbman->add_field($table, $newField);
        upgrade_mod_savepoint(true, 2013070900, 'choicegroup');
    }
    if ($oldversion < 2015022301) {
        $table = new xmldb_table('choicegroup');
        // Adding field to table choicegroup
        $newField = $table->add_field('sortgroupsby', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        if (!$dbman->field_exists($table, $newField)) {
            $dbman->add_field($table, $newField);
        }
        upgrade_mod_savepoint(true, 2015022301, 'choicegroup');
    }
    return true;
}
开发者ID:adamtppaw,项目名称:moodle-mod_choicegroup,代码行数:34,代码来源:upgrade.php


示例3: 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


示例4: xmldb_auth_whia_upgrade

/**
 * Custom authentication for WHIA project
 *
 * Upgrade script
 *
 * @package    auth_whia
 * @author     Bevan Holman <[email protected]>, Pukunui
 * @copyright  2015 onwards, Pukunui
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_auth_whia_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    /// Add a new table mdl_auth_whia_domain to plugin
    if ($oldversion < 2016020802) {
        // Define table auth_rsa_cpdlog to be created.
        $table = new xmldb_table('auth_whia_domain');
        // Adding fields to table auth_rsa_cpdlog.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('name', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table auth_rsa_cpdlog.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for auth_rsa_cpdlog.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // WHIA savepoint reached.
        upgrade_plugin_savepoint(true, 2016020802, 'auth', 'whia');
    }
    if ($oldversion < 2016020813) {
        // Define field cohortid to be added to auth_whia_domain.
        $table = new xmldb_table('auth_whia_domain');
        $field = new xmldb_field('cohortid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'name');
        // Conditionally launch add field cohortid.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Monitor savepoint reached.
        upgrade_plugin_savepoint(true, 2016020813, 'auth', 'whia');
    }
    return true;
}
开发者ID:posttechguy,项目名称:moodle-whia-auth_whia,代码行数:43,代码来源:upgrade.php


示例5: xmldb_repository_onenote_upgrade

/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_repository_onenote_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014103001) {
        // Define table repository_onenote to be created.
        $table = new xmldb_table('repository_onenote');
        // Adding fields to table repository_onenote.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        // Adding keys to table repository_onenote.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for repository_onenote.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Onenote savepoint reached.
        upgrade_plugin_savepoint(true, 2014103001, 'repository', 'onenote');
    }
    // Moodle v2.3.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.4.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:eugeneventer,项目名称:o365-moodle,代码行数:34,代码来源:upgrade.php


示例6: xmldb_opencast_upgrade

function xmldb_opencast_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013120100) {
        // Define fields to be added to table opencast
        $table = new xmldb_table('opencast');
        $field1 = new xmldb_field('userupload', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'inviting');
        $field2 = new xmldb_field('userupload_maxfilesize', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'userupload');
        // Conditionally launch add fields
        if (!$dbman->field_exists($table, $field1)) {
            $dbman->add_field($table, $field1);
        }
        if (!$dbman->field_exists($table, $field2)) {
            $dbman->add_field($table, $field2);
        }
        upgrade_mod_savepoint(true, 2013120100, 'mod', 'opencast');
    }
    if ($oldversion < 2013121600) {
        $table2 = new xmldb_table('opencast_uploadedclip');
        if (!$dbman->table_exists($table2)) {
            $dbman->install_one_table_from_xmldb_file($CFG->dirroot . '/mod/opencast/db/install.xml', 'opencast_uploadedclip');
        }
        upgrade_mod_savepoint(true, 2013121600, 'mod', 'opencast');
    }
    if ($oldversion < 2015070100) {
        // Define table matrix to be created
        $table = new xmldb_table('opencast');
        // Adding fields to table matrix
        $newField = $table->add_field('allow_annotations', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1');
        $dbman->add_field($table, $newField);
        upgrade_plugin_savepoint(true, 2015070100, 'mod', 'opencast');
    }
    return true;
}
开发者ID:ndunand,项目名称:moodle-mod_opencast,代码行数:35,代码来源:upgrade.php


示例7: xmldb_quiz_overview_upgrade

function xmldb_quiz_overview_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    //===== 1.9.0 upgrade line ======//
    if ($oldversion < 2009091400) {
        /// Define table quiz_question_regrade to be created
        $table = new xmldb_table('quiz_question_regrade');
        /// Adding fields to table quiz_question_regrade
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
        $table->add_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
        $table->add_field('regraded', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        /// Adding keys to table quiz_question_regrade
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Conditionally launch create table for quiz_question_regrade
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        /// overview savepoint reached
        upgrade_plugin_savepoint(true, 2009091400, 'quizreport', 'overview');
    }
    return true;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:27,代码来源:upgrade.php


示例8: xmldb_block_oppia_mobile_export_upgrade

function xmldb_block_oppia_mobile_export_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013111402) {
        // block savepoint reached
        upgrade_block_savepoint(true, 2013111402, 'oppia_mobile_export');
    }
    if ($oldversion < 2014032100) {
        // Define table block_oppia_mobile_server to be created.
        $table = new xmldb_table('block_oppia_mobile_server');
        // Adding fields to table block_oppia_mobile_server.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('servername', XMLDB_TYPE_CHAR, '50', null, null, null, '');
        $table->add_field('url', XMLDB_TYPE_CHAR, '50', null, null, null, '');
        $table->add_field('moodleuserid', XMLDB_TYPE_INTEGER, '10', null, null, null, '0');
        $table->add_field('username', XMLDB_TYPE_CHAR, '50', null, null, null, '');
        $table->add_field('apikey', XMLDB_TYPE_CHAR, '50', null, null, null, '');
        $table->add_field('defaultserver', XMLDB_TYPE_INTEGER, '10', null, null, null, '0');
        // Adding keys to table block_oppia_mobile_server.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for block_oppia_mobile_server.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Blocks savepoint reached.
        upgrade_plugin_savepoint(true, 2014032100, 'error', 'blocks');
    }
    if ($oldversion < 2015021802) {
        // Changing type of field value on table block_oppia_mobile_config to text.
        $table = new xmldb_table('block_oppia_mobile_config');
        $field = new xmldb_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
        // Launch change of type for field value.
        $dbman->change_field_type($table, $field);
        // Blocks savepoint reached.
        upgrade_plugin_savepoint(true, 2015021802, 'error', 'blocks');
    }
    if ($oldversion < 2016021500) {
        // Add the field serverid to table block_oppia_mobile_config
        $table = new xmldb_table('block_oppia_mobile_config');
        if (!$dbman->field_exists($table, 'serverid')) {
            $field = new xmldb_field('serverid', XMLDB_TYPE_TEXT, null, null, null, null, null, 'value');
            $dbman->add_field($table, $field);
        }
        // Blocks savepoint reached.
        upgrade_plugin_savepoint(true, 2016021500, 'error', 'blocks');
    }
    if ($oldversion < 2016041301) {
        //Update the size for field value to support longer tag values
        $table = new xmldb_table('block_oppia_mobile_config');
        $field = new xmldb_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
        // Launch change of type for field value.
        $dbman->change_field_type($table, $field);
        // Blocks savepoint reached.
        upgrade_plugin_savepoint(true, 2016041301, 'error', 'blocks');
    }
    return true;
}
开发者ID:chaotic-kingdoms,项目名称:moodle-block_oppia_mobile_export,代码行数:58,代码来源:upgrade.php


示例9: xmldb_hotquestion_upgrade

function xmldb_hotquestion_upgrade($oldversion = 0)
{
    global $CFG, $DB;
    $result = true;
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2007040100) {
        /// Define field course to be added to hotquestion
        $table = new XMLDBTable('hotquestion');
        $field = new XMLDBField('course');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
        /// Launch add field course
        $result = $result && $table->add_field($field);
        /// Define field intro to be added to hotquestion
        $field = new xmldb_field('intro');
        $field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'name');
        /// Launch add field intro
        $result = $result && $table->add_field($field);
        /// Define field introformat to be added to hotquestion
        $field = new xmldb_field('introformat');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
        /// Launch add field introformat
        $result = $result && $table->add_field($field);
    }
    if ($result && $oldversion < 2007040101) {
        /// Define field timecreated to be added to hotquestion
        $table = new xmldb_table('hotquestion');
        $field = new xmldb_field('timecreated');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'introformat');
        /// Launch add field timecreated
        $result = $result && $table->add_field($field);
        $field = new xmldb_field('timemodified');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timecreated');
        /// Launch add field timemodified
        $result = $result && $table->add_field($table, $field);
        /// Define index course (not unique) to be added to hotquestion
        $result = $result && $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
    }
    if ($result && $oldversion < 2007040200) {
        /// Add some actions to get them properly displayed in the logs
        $rec = new stdClass();
        $rec->module = 'hotquestion';
        $rec->action = 'add';
        $rec->mtable = 'hotquestion';
        $rec->filed = 'name';
        /// Insert the add action in log_display
        $result = $DB->insert_record('log_display', $rec);
        /// Now the update action
        $rec->action = 'update';
        $result = $DB->insert_record('log_display', $rec);
        /// Now the view action
        $rec->action = 'view';
        $result = $DB->insert_record('log_display', $rec);
    }
    //===== 2.0 upgrade start here ======//
    return $result;
}
开发者ID:hgthirty,项目名称:moodle-mod_hotquestion,代码行数:56,代码来源:upgrade.php


示例10: get_test_table

 /**
  * Get a xmldb_table object for testing, deleting any existing table
  * of the same name, for example if one was left over from a previous test
  * run that crashed.
  *
  * @param string $suffix table name suffix, use if you need more test tables
  * @return xmldb_table the table object.
  */
 private function get_test_table($suffix = '')
 {
     $tablename = "test_table";
     if ($suffix !== '') {
         $tablename .= $suffix;
     }
     $table = new xmldb_table($tablename);
     $table->setComment("This is a test'n drop table. You can drop it safely");
     return new xmldb_table($tablename);
 }
开发者ID:rama1712,项目名称:moodle,代码行数:18,代码来源:dml_test.php


示例11: xmldb_mediaboard_upgrade

function xmldb_mediaboard_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $DB;
    $result = true;
    $dbman = $DB->get_manager();
    if ($oldversion < 2015030200) {
        // Define table assign_user_mapping to be created.
        $table = new xmldb_table('mediaboard_likes');
        // Adding fields to table assign_user_mapping.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('instance', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('fileid', 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('time', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        // Adding keys to table assign_user_mapping.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('user', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        // Conditionally launch create table for assign_user_mapping.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Assign savepoint reached.
        upgrade_mod_savepoint(true, 2015030200, 'mediaboard');
    }
    return $result;
}
开发者ID:e-rasvet,项目名称:mediaboard,代码行数:26,代码来源:upgrade.php


示例12: xmldb_block_community_upgrade

/**
 *
 * @param int $oldversion
 * @param object $block
 */
function xmldb_block_community_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2010042701) {
        /// Define table block_community to be created
        $table = new xmldb_table('block_community');
        /// Adding fields to table block_community
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('coursename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
        $table->add_field('coursedescription', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
        $table->add_field('courseurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
        $table->add_field('imageurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
        /// Adding keys to table block_community
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Conditionally launch create table for block_community
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        /// community savepoint reached
        upgrade_block_savepoint(true, 2010042701, 'community');
    }
    return true;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:30,代码来源:upgrade.php


示例13: test_reorder_rows

 public function test_reorder_rows()
 {
     global $DB;
     $dbman = $DB->get_manager();
     $this->resetAfterTest();
     $table = new xmldb_table('test_table');
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $tablename = $table->getName();
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('otherid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('otherdata', XMLDB_TYPE_TEXT, 'big', null, null, null);
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('unique', XMLDB_KEY_UNIQUE, array('otherid', 'sortorder'));
     $dbman->create_table($table);
     // Rows intentionally added in a slightly 'random' order.
     // Note we are testing hat the otherid = 1 rows don't get messed up,
     // as well as testing that the otherid = 2 rows are updated correctly.
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 1, 'otherdata' => 'To become 4'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 2, 'otherdata' => 'To become 1'));
     $DB->insert_record($tablename, array('otherid' => 1, 'sortorder' => 1, 'otherdata' => 'Other 1'));
     $DB->insert_record($tablename, array('otherid' => 1, 'sortorder' => 2, 'otherdata' => 'Other 2'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 3, 'otherdata' => 'To stay at 3'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 4, 'otherdata' => 'To become 2'));
     update_field_with_unique_index($tablename, 'sortorder', array(1 => 4, 2 => 1, 3 => 3, 4 => 2), array('otherid' => 2));
     $this->assertEquals(array(3 => (object) array('id' => 3, 'otherid' => 1, 'sortorder' => 1, 'otherdata' => 'Other 1'), 4 => (object) array('id' => 4, 'otherid' => 1, 'sortorder' => 2, 'otherdata' => 'Other 2')), $DB->get_records($tablename, array('otherid' => 1), 'sortorder'));
     $this->assertEquals(array(2 => (object) array('id' => 2, 'otherid' => 2, 'sortorder' => 1, 'otherdata' => 'To become 1'), 6 => (object) array('id' => 6, 'otherid' => 2, 'sortorder' => 2, 'otherdata' => 'To become 2'), 5 => (object) array('id' => 5, 'otherid' => 2, 'sortorder' => 3, 'otherdata' => 'To stay at 3'), 1 => (object) array('id' => 1, 'otherid' => 2, 'sortorder' => 4, 'otherdata' => 'To become 4')), $DB->get_records($tablename, array('otherid' => 2), 'sortorder'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:28,代码来源:datalib_update_with_unique_index_test.php


示例14: xmldb_assignfeedback_poodll_upgrade

/**
 * Stub for upgrade code
 * @param int $oldversion
 * @return bool
 */
function xmldb_assignfeedback_poodll_upgrade($oldversion)
{
    // do the upgrades
    //add filename field
    if ($oldversion < 2013120500) {
        $table = new xmldb_table('assignfeedback_poodll');
        $table->add_field('filename', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
        // online PoodLL savepoint reached
        upgrade_plugin_savepoint(true, 2013120500, 'assignfeedback', 'poodll');
    }
    return true;
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:17,代码来源:upgrade.php


示例15: xmldb_reader_upgrade

function xmldb_reader_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $DB;
    if ($oldversion < 2012010702) {
        //$DB->execute("ALTER TABLE {reader} ADD `introformat` INT( 10 ) NULL DEFAULT '0' AFTER `intro`");
        // Define table quiz_report to be created
        $table = new xmldb_table('reader');
        // Adding fields to table quiz_report
        $table->add_field('introformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NULL, XMLDB_SEQUENCE, null);
        upgrade_mod_savepoint(true, 2012010702, 'reader');
    }
    $result = true;
    return $result;
}
开发者ID:e-rasvet,项目名称:reader,代码行数:14,代码来源:upgrade.php


示例16: xmldb_scorm_upgrade

/**
 * @global moodle_database $DB
 * @param int $oldversion
 * @return bool
 */
function xmldb_scorm_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2012032100) {
        unset_config('updatetime', 'scorm');
        upgrade_mod_savepoint(true, 2012032100, 'scorm');
    }
    // Adding completion fields to scorm table
    if ($oldversion < 2012032101) {
        $table = new xmldb_table('scorm');
        $field = new xmldb_field('completionstatusrequired', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'timemodified');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        $field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, 'completionstatusrequired');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_mod_savepoint(true, 2012032101, 'scorm');
    }
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    //rename config var from maxattempts to maxattempt
    if ($oldversion < 2012061701) {
        $maxattempts = get_config('scorm', 'maxattempts');
        $maxattempts_adv = get_config('scorm', 'maxattempts_adv');
        set_config('maxattempt', $maxattempts, 'scorm');
        set_config('maxattempt_adv', $maxattempts_adv, 'scorm');
        unset_config('maxattempts', 'scorm');
        //remove old setting.
        unset_config('maxattempts_adv', 'scorm');
        //remove old setting.
        upgrade_mod_savepoint(true, 2012061701, 'scorm');
    }
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2015101301) {
        // Define table scorm_scoes_item to be created.
        $table = new xmldb_table('scorm_scoes_item');
        // Adding fields to table scorm_scoes_item.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('scorm_scoes_track_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        $table->add_field('field_id', XMLDB_TYPE_CHAR, '255', null, null, null, null);
        $table->add_field('field_text', XMLDB_TYPE_CHAR, '255', null, null, null, null);
        $table->add_field('field_value', XMLDB_TYPE_CHAR, '255', null, null, null, null);
        // Adding keys to table scorm_scoes_item.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for scorm_scoes_item.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Scorm savepoint reached.
        upgrade_mod_savepoint(true, 2015101301, 'scorm');
    }
    return true;
}
开发者ID:Healthcare-Learning,项目名称:TCAPI-Moodle-SCORM-mod,代码行数:64,代码来源:upgrade.php


示例17: xmldb_voiceshadow_upgrade

function xmldb_voiceshadow_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $DB;
    $result = true;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013030200) {
        $table = new xmldb_table('voiceshadow');
        $field = new xmldb_field('allowmultiple', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'emailteachers');
        // Conditionally launch add field requiresubmissionstatement.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Assign savepoint reached.
        upgrade_mod_savepoint(true, 2013030200, 'voiceshadow');
    }
    if ($oldversion < 2014030200) {
        // Define table assign_user_mapping to be created.
        $table = new xmldb_table('voiceshadow_likes');
        // Adding fields to table assign_user_mapping.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('instance', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('fileid', 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('time', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        // Adding keys to table assign_user_mapping.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('user', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        // Conditionally launch create table for assign_user_mapping.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Assign savepoint reached.
        upgrade_mod_savepoint(true, 2014030200, 'voiceshadow');
    }
    if ($oldversion < 2014080400) {
        // Define table assign_user_mapping to be created.
        $table = new xmldb_table('voiceshadow');
        $field = new xmldb_field('gradet', XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, '0', 'grade');
        // Conditionally launch add field.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        $field = new xmldb_field('grademethodt', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'default', 'grademethod');
        // Conditionally launch add field.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Assign savepoint reached.
        upgrade_mod_savepoint(true, 2014080400, 'voiceshadow');
    }
    return $result;
}
开发者ID:e-rasvet,项目名称:voiceshadow,代码行数:52,代码来源:upgrade.php


示例18: xmldb_block_nurs_navigation_upgrade

/**
 * This is the upgrade script for the project.
 *
 * @package    block_nurs_navigation
 * @category   block
 * @copyright  2012 Craig Jamieson
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_block_nurs_navigation_upgrade($oldversion = 0)
{
    global $DB;
    $dbman = $DB->get_manager();
    $result = true;
    // June 17, 2013 version changed the way that contexts are stored in the files table.
    if ($oldversion < 2013061706) {
        $query = "SELECT * FROM {nurs_navigation} WHERE courseid <> 1";
        $records = $DB->get_records_sql($query);
        $fs = get_file_storage();
        foreach ($records as $record) {
            $coursecontext = context_course::instance($record->courseid);
            // Explicit check here since sometimes there are old nurs_navigation records that point to deleted courses.
            if (isset($coursecontext->id)) {
                $params = array($coursecontext->id, 'nurs_navigation');
                $query = "SELECT * FROM {block_instances} WHERE parentcontextid = ? AND blockname = ?";
                $block = $DB->get_record_sql($query, $params, IGNORE_MULTIPLE);
                $blockcontext = context_block::instance($block->id);
                // This can return multiple records because of how the multiple file terminator works.
                $filerecords = $DB->get_records('files', array('contextid' => $coursecontext->id, 'itemid' => $record->fileid));
                foreach ($filerecords as $filerecord) {
                    $filerecord->contextid = $blockcontext->id;
                    // Path hash must be updated as well with a context change.
                    $filerecord->pathnamehash = $fs->get_pathname_hash($filerecord->contextid, BNN_BLOCK_SAVE_COMPONENT, BNN_BLOCK_SAVE_AREA, $filerecord->itemid, $filerecord->filepath, $filerecord->filename);
                    $DB->update_record('files', $filerecord);
                }
            }
        }
    }
    // Create the second table.
    if ($oldversion < 2012110200) {
        // Define table nurs_navigation_settings to be created.
        $table = new xmldb_table('nurs_navigation_settings');
        // Adding fields to table nurs_navigation_settings.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null);
        $table->add_field('sectionname', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null);
        $table->add_field('disableicon', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null);
        $table->add_field('customlabel', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
        // Adding keys to table nurs_navigation_settings.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for nurs_navigation_settings.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Define field disableicon to be dropped from nurs_navigation.
        $table = new xmldb_table('nurs_navigation');
        $field = new xmldb_field('disableicon');
        // Conditionally launch drop field courseid.
        if ($dbman->field_exists($table, $field)) {
            $dbman->drop_field($table, $field);
        }
        // Update savepoint.
        upgrade_block_savepoint(true, 2012110200, 'nurs_navigation');
    }
    return $result;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:65,代码来源:upgrade.php


示例19: xmldb_qtype_calculated_upgrade

function xmldb_qtype_calculated_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    $result = true;
    // MDL-16505.
    if ($result && $oldversion < 2008091700) {
        //New version in version.php
        if (get_config('qtype_datasetdependent', 'version')) {
            $result = $result && unset_config('version', 'qtype_datasetdependent');
        }
        upgrade_plugin_savepoint($result, 2008091700, 'qtype', 'calculated');
    }
    //    let if ($dbman->table_exists()) replace the normal $oldversion test
    //    as in any case the question question_calculated_options should be created
    /// Define table question_calculated_options to be created
    $table = new xmldb_table('question_calculated_options');
    /// Adding fields to table question_calculated_options
    $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
    $table->add_field('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
    $table->add_field('synchronize', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
    /// Adding keys to table question_calculated_options
    $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->add_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
    /// Conditionally launch create table for question_calculated_options
    if (!$dbman->table_exists($table)) {
        $result = $dbman->create_table($table);
    }
    /// calculated savepoint reached
    /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
    ///     $result = result of database_manager methods
    ///     upgrade_plugin_savepoint($result, YYYYMMDD00, 'qtype', 'calculated');
    /// }
    return $result;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:35,代码来源:upgrade.php


示例20: xmldb_enrol_uaims_upgrade

function xmldb_enrol_uaims_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014110600) {
        // Define table eclass_course_management to be created.
        $table = new xmldb_table('eclass_course_management');
        // Adding fields to table eclass_course_management.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null);
        $table->add_field('startdate', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('enddate', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('lastopened', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, '0' 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP xmlrpc_client类代码示例发布时间:2022-05-23
下一篇:
PHP xmldb_index类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap