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


PHP XMLDBIndex::setAttributes方法代码示例

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


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

示例1: xmldb_taoresource_upgrade

function xmldb_taoresource_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    /// And upgrade begins here. For each one, you'll need one
    /// block of code similar to the next one. Please, delete
    /// this comment lines once this file start handling proper
    /// upgrade code.
    /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
    ///     $result = result of "/lib/ddllib.php" function calls
    /// }
    //===== 1.9.0 upgrade line ======//
    // change the remoteid key to be non-unique
    if ($result && $oldversion < 2007101510) {
        $table = new XMLDBTable('taoresource_entry');
        $index = new XMLDBIndex('remoteid');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('remoteid'));
        if (index_exists($table, $index)) {
            $result = $result && drop_index($table, $index);
        }
        $result = $result && add_index($table, $index);
    }
    // change the remoteid key to be non-unique
    if ($result && $oldversion < 2007101511) {
        $table = new XMLDBTable('taoresource_metadata');
        $field = new XMLDBField('entry_id');
        // change the field type from ext to int
        if (field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
            $result = $result && change_field_type($table, $field);
        }
    }
    return $result;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:34,代码来源:upgrade.php

示例2: xmldb_block_student_gradeviewer_upgrade

function xmldb_block_student_gradeviewer_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010070912) {
        /// Define field opt to be dropped from block_teacher_referral_opt
        $table = new XMLDBTable('block_teacher_referral_opt');
        // First let's drop the index
        $index = new XMLDBIndex('bloc_tea_usesec_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'sectionsid'));
        $failing_field = new XMLDBField('failing');
        $lagging_field = new XMLDBField('lagging');
        $usersid_field = new XMLDBField('usersid');
        /// Launch drop field opt
        $result = $result && drop_index($table, $index) && drop_field($table, $usersid_field) && drop_field($table, $lagging_field) && drop_field($table, $failing_field);
        // Add the following fields
        $fields = array('sectionsid', 'primary_instructor', 'non_primary_instructor', 'student', 'non_primary_control');
        foreach (range(1, count($fields) - 1) as $index) {
            $field = new XMLDBField($fields[$index]);
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $fields[$index - 1]);
            $result = $result && add_field($table, $field);
        }
        $index = new XMLDBIndex('bloc_tea_usesec_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('sectionsid'));
        $result = $result && add_index($table, $index);
    }
    return $result;
}
开发者ID:rrusso,项目名称:EARS,代码行数:28,代码来源:upgrade.php

示例3: xmldb_search_elasticsearch_upgrade

function xmldb_search_elasticsearch_upgrade($oldversion = 0)
{
    if ($oldversion < 2015012800) {
        // Adding indices on the table search_elasticsearch_queue
        $table = new XMLDBTable('search_elasticsearch_queue');
        $index = new XMLDBIndex('itemidix');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('itemid'));
        add_index($table, $index);
    }
    if ($oldversion < 2015060900) {
        log_debug('Add "status" and "lastprocessed" columns to search_elasticsearch_queue table');
        $table = new XMLDBTable('search_elasticsearch_queue');
        $field = new XMLDBField('status');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
        $table = new XMLDBTable('search_elasticsearch_queue');
        $field = new XMLDBField('lastprocessed');
        $field->setAttributes(XMLDB_TYPE_DATETIME);
        add_field($table, $field);
        $table = new XMLDBTable('search_elasticsearch_queue');
        $index = new XMLDBIndex('statusix');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('status'));
        add_index($table, $index);
    }
    if ($oldversion < 2015072700) {
        log_debug('Adding ability to search by "Text" blocks in elasticsearch');
        // Need to add the 'block_instance' to the default types to index for elasticsearch
        // Note: the $cfg->plugin_search_elasticsearch_types can be overriding this
        // We don't want to run the re-indexing now as that will take ages for large sites
        // It should be run from the  Extensions -> Elasticsearch -> Configuration page
        if ($types = get_field('search_config', 'value', 'plugin', 'elasticsearch', 'field', 'types')) {
            $types = explode(',', $types);
            if (!in_array('block_instance', $types)) {
                $types[] = 'block_instance';
            }
            $types = implode(',', $types);
            update_record('search_config', array('value' => $types), array('plugin' => 'elasticsearch', 'field' => 'types'));
            log_warn(get_string('newindextype', 'search.elasticsearch', 'block_instance'), true, false);
        }
    }
    if ($oldversion < 2015100800) {
        log_debug('Adding ability to search by collection in elasticsearch');
        // The code for this existed since the beginning but 'collection' was not
        // added to the $cfg->plugin_search_elasticsearch_types
        // We don't want to run the re-indexing now as that will take ages for large sites
        // It should be run from the  Extensions -> Elasticsearch -> Configuration page
        if ($types = get_field('search_config', 'value', 'plugin', 'elasticsearch', 'field', 'types')) {
            $types = explode(',', $types);
            if (!in_array('collection', $types)) {
                $types[] = 'collection';
            }
            $types = implode(',', $types);
            update_record('search_config', array('value' => $types), array('plugin' => 'elasticsearch', 'field' => 'types'));
            log_warn(get_string('newindextype', 'search.elasticsearch', 'collection'), true, false);
        }
    }
    return true;
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:58,代码来源:upgrade.php

示例4: xmldb_search_elasticsearch_upgrade

function xmldb_search_elasticsearch_upgrade($oldversion = 0)
{
    if ($oldversion < 2015012800) {
        // Adding indices on the table search_elasticsearch_queue
        $table = new XMLDBTable('search_elasticsearch_queue');
        $index = new XMLDBIndex('itemidix');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('itemid'));
        add_index($table, $index);
    }
    return true;
}
开发者ID:vohung96,项目名称:mahara,代码行数:11,代码来源:upgrade.php

示例5: xmldb_elis_core_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * 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/>.
 *
 * @package    elis
 * @subpackage core
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_elis_core_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2011030402) {
        /***********************************************************************
         * Replace plugintype and pluginname with plugin field
         **********************************************************************/
        /// Define field plugin to be added to elis_scheduled_tasks
        $table = new XMLDBTable('elis_scheduled_tasks');
        $field = new XMLDBField('plugin');
        $field->setAttributes(XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null, 'id');
        /// Launch add field plugin
        $result = $result && add_field($table, $field);
        /// Define index plugin_idx (not unique) to be dropped form elis_scheduled_tasks
        $index = new XMLDBIndex('plugin_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugintype', 'pluginname', 'taskname'));
        /// Launch drop index plugin_idx
        $result = $result && drop_index($table, $index);
        /// Define index plugin_idx (not unique) to be added to elis_scheduled_tasks
        $index = new XMLDBIndex('plugin_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugin', 'taskname'));
        /// Launch add index plugin_idx
        $result = $result && add_index($table, $index);
        /// Define field plugin to be dropped from elis_scheduled_tasks
        $field = new XMLDBField('plugintype');
        /// Launch drop field plugin
        $result = $result && drop_field($table, $field);
        /// Define field plugin to be dropped from elis_scheduled_tasks
        $field = new XMLDBField('pluginname');
        /// Launch drop field plugin
        $result = $result && drop_field($table, $field);
        /***********************************************************************
         * Change callfunction from text to char
         **********************************************************************/
        /// Changing type of field callfunction on table elis_scheduled_tasks to char
        $field = new XMLDBField('callfunction');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'callfile');
        /// Launch change of type for field callfunction
        $result = $result && change_field_type($table, $field);
    }
    if ($result && $oldversion < 2011030403) {
        /// Define field startdate to be added to elis_scheduled_tasks
        $table = new XMLDBTable('elis_scheduled_tasks');
        $field = new XMLDBField('startdate');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'runsremaining');
        /// Launch add field startdate
        $result = $result && add_field($table, $field);
    }
    return $result;
}
开发者ID:benavidesrobert,项目名称:elis.base,代码行数:75,代码来源:upgrade.php

示例6: xmldb_quiz_upgrade

function xmldb_quiz_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    /// And upgrade begins here. For each one, you'll need one
    /// block of code similar to the next one. Please, delete
    /// this comment lines once this file start handling proper
    /// upgrade code.
    if ($result && $oldversion < 2007022800) {
        /// Ensure that there are not existing duplicate entries in the database.
        $duplicateunits = get_records_select('question_numerical_units', "id > (SELECT MIN(iqnu.id)\n                FROM {$CFG->prefix}question_numerical_units iqnu\n                WHERE iqnu.question = {$CFG->prefix}question_numerical_units.question AND\n                        iqnu.unit = {$CFG->prefix}question_numerical_units.unit)", '', 'id');
        if ($duplicateunits) {
            delete_records_select('question_numerical_units', 'id IN (' . implode(',', array_keys($duplicateunits)) . ')');
        }
        /// Define index question-unit (unique) to be added to question_numerical_units
        $table = new XMLDBTable('question_numerical_units');
        $index = new XMLDBIndex('question-unit');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('question', 'unit'));
        /// Launch add index question-unit
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007070200) {
        /// Changing precision of field timelimit on table quiz to (10)
        $table = new XMLDBTable('quiz');
        $field = new XMLDBField('timelimit');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timemodified');
        /// Launch change of precision for field timelimit
        $result = $result && change_field_precision($table, $field);
    }
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/quiz/lib.php';
        // too much debug output
        $db->debug = false;
        quiz_update_grades();
        $db->debug = true;
    }
    // Separate control for when overall feedback is displayed, independant of the question feedback settings.
    if ($result && $oldversion < 2007072600) {
        // Adjust the quiz review options so that overall feedback is displayed whenever feedback is.
        $result = $result && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' . sql_bitor(sql_bitand('review', sql_bitnot(QUIZ_REVIEW_OVERALLFEEDBACK)), sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) . ' * 65536', sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) . ' * 16384', sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) . ' * 4096'))));
        // Same adjustment to the defaults for new quizzes.
        $result = $result && set_config('quiz_review', $CFG->quiz_review & ~QUIZ_REVIEW_OVERALLFEEDBACK | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) << 16 | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) << 14 | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) << 12);
    }
    //===== 1.9.0 upgrade line ======//
    return $result;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:46,代码来源:upgrade.php

示例7: postinst

 public static function postinst($prevversion)
 {
     if ($prevversion == 0) {
         if (is_postgres()) {
             $table = new XMLDBTable('blocktype_externalfeed_data');
             $index = new XMLDBIndex('urlautautix');
             $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
             add_index($table, $index);
         } else {
             if (is_mysql()) {
                 // MySQL needs size limits when indexing text fields
                 execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
                            {blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
             }
         }
     }
 }
开发者ID:vohung96,项目名称:mahara,代码行数:17,代码来源:lib.php

示例8: xmldb_local_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * 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/>.
 *
 * @package    elis
 * @subpackage curriculummanagement
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_local_upgrade($oldversion)
{
    global $CFG, $db;
    $result = true;
    if ($result && $oldversion < 2010110800) {
        $table = new XMLDBTable('user_info_data');
        $index = new XMLDBIndex('useridx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
        $result = $result && add_index($table, $index);
        $index = new XMLDBIndex('fieldidx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('fieldid'));
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2011033100) {
        // Changing size of field 'name' on 'user_preferences' from 50 to 255
        $table = new XMLDBTable('user_preferences');
        $field = new XMLDBField('name');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'userid');
        // Launch change of precision for field name
        $result = $result && change_field_precision($table, $field);
    }
    return $result;
}
开发者ID:benavidesrobert,项目名称:elis.base,代码行数:47,代码来源:upgrade.php

示例9: xmldb_block_php_report_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * 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/>.
 *
 * @package    elis
 * @subpackage php_reports
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_block_php_report_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2011040600) {
        /// Define table php_report_schedule to be created
        $table = new XMLDBTable('php_report_schedule');
        /// Adding fields to table php_report_schedule
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('report', XMLDB_TYPE_CHAR, '63', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('config', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table php_report_schedule
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Adding indexes to table php_report_schedule
        $table->addIndexInfo('report_idx', XMLDB_INDEX_NOTUNIQUE, array('report'));
        /// Launch create table for php_report_schedule
        $result = $result && create_table($table);
        /// Define field userid to be added to php_report_schedule
        $table = new XMLDBTable('php_report_schedule');
        $field = new XMLDBField('userid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
        /// Launch add field userid
        $result = $result && add_field($table, $field);
        /// Define index userid_idx (not unique) to be added to php_report_schedule
        $table = new XMLDBTable('php_report_schedule');
        $index = new XMLDBIndex('userid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
        /// Launch add index userid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2011042900) {
        $query = "name " . sql_ilike() . " 'php_report%'";
        $result = $result && delete_records_select('user_preferences', $query);
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:60,代码来源:upgrade.php

示例10: xmldb_data_upgrade

function xmldb_data_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    /// And upgrade begins here. For each one, you'll need one
    /// block of code similar to the next one. Please, delete
    /// this comment lines once this file start handling proper
    /// upgrade code.
    /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
    ///     $result = result of "/lib/ddllib.php" function calls
    /// }
    if ($result && $oldversion < 2006121300) {
        /// Define field format to be added to data_comments
        $table = new XMLDBTable('data_comments');
        $field = new XMLDBField('format');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'content');
        /// Launch add field format
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007022600) {
        /// Define field asearchtemplate to be added to data
        $table = new XMLDBTable('data');
        $field = new XMLDBField('asearchtemplate');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
        /// Launch add field asearchtemplate
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/data/lib.php';
        // too much debug output
        $db->debug = false;
        data_update_grades();
        $db->debug = true;
    }
    if ($result && $oldversion < 2007081400) {
        /// Define field notification to be added to data
        $table = new XMLDBTable('data');
        $field = new XMLDBField('notification');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'editany');
        /// Launch add field notification
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007081402) {
        /// Define index type-dataid (not unique) to be added to data_fields
        $table = new XMLDBTable('data_fields');
        $index = new XMLDBIndex('type-dataid');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('type', 'dataid'));
        /// Launch add index type-dataid
        if (!index_exists($table, $index)) {
            $result = $result && add_index($table, $index);
        }
        /// Define index course (not unique) to be added to data
        $table = new XMLDBTable('data');
        $index = new XMLDBIndex('course');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
        /// Launch add index course
        if (!index_exists($table, $index)) {
            $result = $result && add_index($table, $index);
        }
    }
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2007101512) {
        /// Launch add field asearchtemplate again if does not exists yet - reported on several sites
        $table = new XMLDBTable('data');
        $field = new XMLDBField('asearchtemplate');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
    }
    return $result;
}
开发者ID:r007,项目名称:PMoodle,代码行数:72,代码来源:upgrade.php

示例11: xmldb_blocktype_externalfeed_upgrade

function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
    if ($oldversion < 2008042101) {
        // We hit the 255 character limit for feed URLs
        if (is_postgres()) {
            execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
        } else {
            if (is_mysql()) {
                // If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
                // We have to remove then add the constraint again else the change will make MySQL cry
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
            }
        }
    }
    if ($oldversion < 2009121600) {
        if (is_mysql()) {
            // Make content column wider (TEXT is only 65kb in mysql)
            $table = new XMLDBTable('blocktype_externalfeed_data');
            $field = new XMLDBField('content');
            $field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
            change_field_precision($table, $field);
        }
    }
    if ($oldversion < 2010073000) {
        execute_sql('
            UPDATE {blocktype_cron}
            SET minute = ?
            WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
    }
    if ($oldversion < 2011091400) {
        // Add columns for HTTP basic auth
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field1 = new XMLDBField('authuser');
        $field1->setAttributes(XMLDB_TYPE_TEXT);
        $field2 = new XMLDBField('authpassword');
        $field2->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field1);
        add_field($table, $field2);
        // Change unique constraint that's no longer valid
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $index = new XMLDBIndex('url_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('url'));
        drop_index($table, $index);
        if (is_postgres()) {
            $index = new XMLDBIndex('urlautautix');
            $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
            add_index($table, $index);
        } else {
            if (is_mysql()) {
                // MySQL needs size limits when indexing text fields
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
                           {blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
            }
        }
    }
    if ($oldversion < 2011091401) {
        // Add columns for insecure SSL mode
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field = new XMLDBField('insecuresslmode');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
    }
    if ($oldversion < 2012090700) {
        // Reset all feeds to reset themselves
        set_field('blocktype_externalfeed_data', 'lastupdate', db_format_timestamp('0'));
        safe_require('blocktype', 'externalfeed');
        call_static_method('PluginBlocktypeExternalfeed', 'refresh_feeds');
    }
    if ($oldversion < 2014041500) {
        log_debug('Cleaning up duplicate feeds in the externalfeed blocktype');
        log_debug('1. Find the duplicate feed urls');
        // Setting these to be empty strings instead of NULL will make our SQL a lot simpler in the next section
        execute_sql("update {blocktype_externalfeed_data} set authuser='' where authuser is null");
        execute_sql("update {blocktype_externalfeed_data} set authpassword='' where authpassword is null");
        if ($duplicatefeeds = get_records_sql_array("SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_externalfeed_data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY url, authuser, authpassword", array())) {
            log_debug('2. Get all feed ids for the duplicated feed urls');
            // Use the 1st one found to be the feed id for the block instances that need updating
            $feedstoupdate = array();
            foreach ($duplicatefeeds as $feed) {
                $feedids = get_column('blocktype_externalfeed_data', 'id', 'url', $feed->url, 'authuser', $feed->authuser, 'authpassword', $feed->authpassword);
                $feedstoupdate[$feed->url] = $feedids;
            }
            log_debug('3. Updating blocks to use correct feed id');
            // Find the block instances using external feeds. Check to see if they are not using the 'true' id and update them accordingly
            require_once get_config('docroot') . 'blocktype/lib.php';
            $blockids = get_records_array('block_instance', 'blocktype', 'externalfeed', 'id ASC', 'id');
            foreach ($blockids as $blockid) {
                $blockinstance = new BlockInstance($blockid->id);
                $configdata = $blockinstance->get('configdata');
                if (!empty($configdata['feedid'])) {
                    foreach ($feedstoupdate as $url => $ids) {
                        foreach ($ids as $key => $id) {
                            if ($id == $configdata['feedid'] && $key != '0') {
                                $configdata['feedid'] = $ids[0];
                                $blockinstance->set('configdata', $configdata);
                                $blockinstance->set('dirty', true);
                                $blockinstance->commit();
                                break;
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:upgrade.php

示例12: getDbTables

 private static function getDbTables()
 {
     $tables = array();
     // globalmessages table
     $table = new XMLDBTable('local_globalmessages');
     $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
     $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('summary', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
     $table->addFieldInfo('description', XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('created', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('modified', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('status', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
     $table->addFieldInfo('design', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
     $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
     $index = new XMLDBIndex('design');
     $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('design'));
     $table->addIndex($index);
     $index = new XMLDBIndex('modified');
     $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('modified'));
     $table->addIndex($index);
     $tables[] = $table;
     // globalmessages_designs table
     $table = new XMLDBTable('local_globalmessages_designs');
     $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
     $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('height', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 400);
     $table->addFieldInfo('width', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 400);
     $table->addFieldInfo('bgcolor', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
     $table->addFieldInfo('bgimage', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
     $table->addFieldInfo('bgimageposition', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
     $table->addFieldInfo('bgimagerepeat', XMLDB_TYPE_CHAR, '50', null, null, null, null, null, null);
     $table->addFieldInfo('bordersize', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
     $table->addFieldInfo('bordercolor', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
     $table->addFieldInfo('bordershape', XMLDB_TYPE_CHAR, '50', null, null, null, null, null, null);
     $table->addFieldInfo('padding', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
     $table->addFieldInfo('innerpadding', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
     $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
     $tables[] = $table;
     // globalmessages_rules table
     $table = new XMLDBTable('local_globalmessages_rules');
     $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
     $table->addFieldInfo('construct', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('leftside', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('operator', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('rightside', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('message', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
     $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
     $index = new XMLDBIndex('message');
     $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('message'));
     $table->addIndex($index);
     $tables[] = $table;
     return $tables;
 }
开发者ID:POETGroup,项目名称:moodle-local_globalmessage,代码行数:53,代码来源:base.php

示例13: xmldb_local_upgrade

function xmldb_local_upgrade($oldversion)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2008032500) {
        /// Define table backup_guids to be created
        $table = new XMLDBTable('backup_guids');
        /// Adding fields to table backup_guids
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('guid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('src_table', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('src_field', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('src_value', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table backup_guids
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        //     $table->addKeyInfo('backup_guids_uk', XMLDB_KEY_UNIQUE, array('src_table', 'src_field', 'src_value'));
        /// Adding indexes to table backup_guids
        $table->addIndexInfo('guid_idx', XMLDB_INDEX_UNIQUE, array('guid'));
        /// Launch create table for backup_guids
        $result = $result && create_table($table);
        /// Define table restore_guids to be created
        $table = new XMLDBTable('restore_guids');
        /// Adding fields to table restore_guids
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('guid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('src_table', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('src_field', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('src_value', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table restore_guids
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        // uncommenting this key - it doesn't work for mysql users.
        //       $table->addKeyInfo('backup_guids_uk', XMLDB_KEY_UNIQUE, array('src_table', 'src_field', 'src_value'));
        /// Adding indexes to table restore_guids
        $table->addIndexInfo('guid_idx', XMLDB_INDEX_UNIQUE, array('guid'));
        /// Launch create table for restore_guids
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2008032501) {
        /// Define field src_value to be dropped from backup_guids
        $table = new XMLDBTable('backup_guids');
        $field = new XMLDBField('courseid');
        /// Launch drop field src_value
        $result = $result && drop_field($table, $field);
    }
    if ($result && $oldversion < 2008032602) {
        /// Define key backup_guids_uk (unique) to be dropped form restore_guids
        $table = new XMLDBTable('restore_guids');
        $key = new XMLDBKey('backup_guids_uk');
        $key->setAttributes(XMLDB_KEY_UNIQUE, array('src_table', 'src_field', 'src_value', 'courseid'));
        /// Launch drop key backup_guids_uk
        $result = $result && drop_key($table, $key);
        /// Define key backup_guids_uk (unique) to be added to restore_guids
        //      $table = new XMLDBTable('restore_guids');
        //       $key = new XMLDBKey('backup_guids_uk');
        //       $key->setAttributes(XMLDB_KEY_UNIQUE, array('src_table', 'src_field', 'src_value', 'courseid'));
        /// Launch add key backup_guids_uk
        //        $result = $result && add_key($table, $key);
        /// Define index guid_idx (not unique) to be dropped form restore_guids
        $table = new XMLDBTable('restore_guids');
        $index = new XMLDBIndex('guid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('guid'));
        /// Launch drop index guid_idx
        $result = $result && drop_index($table, $index);
        /// Define index guid_idx (not unique) to be added to restore_guids
        $table = new XMLDBTable('restore_guids');
        $index = new XMLDBIndex('guid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('guid'));
        /// Launch add index guid_idx
        $result = $result && add_index($table, $index);
    }
    //new incremental_courses table.
    if ($result && $oldversion < 2008041101) {
        // new incremental table.
        /// Define table to be created
        $table = new XMLDBTable('incremental_courses');
        /// Adding fields to table
        $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, null, null, null, null, null);
        $table->addFieldInfo('laststarttime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
        $table->addFieldInfo('lastendtime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
        $table->addFieldInfo('laststatus', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null);
        $table->addFieldInfo('nextstarttime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
        /// Adding keys to table
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Launch create table
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2008041102) {
        //new incremental_instance table.
        /// Define table
        $table = new XMLDBTable('incremental_instance');
        /// Adding fields to table
        $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('filename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('hash', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:upgrade.php

示例14: upgrade_18_groups_drop_keys_indexes

/**
 * Drop keys & indexes for groups upgrade from 1.8.*
 */
function upgrade_18_groups_drop_keys_indexes()
{
    $result = true;
    /// Define index groupid-courseid (unique) to be added to groups_members
    $table = new XMLDBTable('groups_members');
    $index = new XMLDBIndex('groupid-courseid');
    $index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupid', 'userid'));
    $result = $result && drop_index($table, $index);
    /// Define key courseid (foreign) to be added to groups_courses_groups
    $table = new XMLDBTable('groups_courses_groups');
    $key = new XMLDBKey('courseid');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
    $result = $result && drop_key($table, $key);
    /// Define key groupid (foreign) to be added to groups_courses_groups
    $table = new XMLDBTable('groups_courses_groups');
    $key = new XMLDBKey('groupid');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
    $result = $result && drop_key($table, $key);
    /// Define index courseid-groupid (unique) to be added to groups_courses_groups
    $table = new XMLDBTable('groups_courses_groups');
    $index = new XMLDBIndex('courseid-groupid');
    $index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupid'));
    $result = $result && drop_index($table, $index);
    /// Define key courseid (foreign) to be added to groups_courses_groupings
    $table = new XMLDBTable('groups_courses_groupings');
    $key = new XMLDBKey('courseid');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
    $result = $result && drop_key($table, $key);
    /// Define key groupingid (foreign) to be added to groups_courses_groupings
    $table = new XMLDBTable('groups_courses_groupings');
    $key = new XMLDBKey('groupingid');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
    $result = $result && drop_key($table, $key);
    /// Define index courseid-groupingid (unique) to be added to groups_courses_groupings
    $table = new XMLDBTable('groups_courses_groupings');
    $index = new XMLDBIndex('courseid-groupingid');
    $index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupingid'));
    $result = $result && drop_index($table, $index);
    /// Define key groupingid (foreign) to be added to groups_groupings_groups
    $table = new XMLDBTable('groups_groupings_groups');
    $key = new XMLDBKey('groupingid');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
    $result = $result && drop_key($table, $key);
    /// Define key groupid (foreign) to be added to groups_groupings_groups
    $table = new XMLDBTable('groups_groupings_groups');
    $key = new XMLDBKey('groupid');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
    $result = $result && drop_key($table, $key);
    /// Define index groupingid-groupid (unique) to be added to groups_groupings_groups
    $table = new XMLDBTable('groups_groupings_groups');
    $index = new XMLDBIndex('groupingid-groupid');
    $index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupingid', 'groupid'));
    $result = $result && drop_index($table, $index);
    return $result;
}
开发者ID:r007,项目名称:PMoodle,代码行数:58,代码来源:upgradelib.php

示例15: xmldb_dialogue_upgrade

function xmldb_dialogue_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007100300) {
        /// Define field recipientid to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('recipientid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'userid');
        /// Launch add field recipientid
        $result = $result && add_field($table, $field);
        $index = new XMLDBIndex('dialogue_entries_recipientid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('recipientid'));
        /// Launch add index dialogue_entries_recipientid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007100301) {
        /// Define field lastrecipientid to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('lastrecipientid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'lastid');
        /// Launch add field lastrecipientid
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007100400) {
        /// Define field attachment to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('attachment');
        $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'text');
        /// Launch add field attachment
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007100800) {
        /// Define field edittime to be added to dialogue
        $table = new XMLDBTable('dialogue');
        $field = new XMLDBField('edittime');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
        /// Launch add field edittime
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007110700) {
        /// Define field groupid to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('groupid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'subject');
        /// Launch add field groupid
        $result = $result && add_field($table, $field);
        /// Define index dialogue_conversations_groupid_idx (not unique) to be added to dialogue_conversations
        $index = new XMLDBIndex('dialogue_conversations_groupid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('groupid'));
        /// Launch add index dialogue_conversations_groupid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007110800) {
        /// Define field grouping to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('grouping');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'groupid');
        /// Launch add field grouping
        $result = $result && add_field($table, $field);
        /// Define index dialogue_conversations_grouping_idx (not unique) to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $index = new XMLDBIndex('dialogue_conversations_grouping_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('grouping'));
        /// Launch add index dialogue_conversations_grouping_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007111401) {
        /// Define field timemodified to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('timemodified');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0', 'timecreated');
        /// Launch add field timemodified
        $result = $result && add_field($table, $field);
        $result = $result && ($result = execute_sql('UPDATE ' . $CFG->prefix . 'dialogue_entries SET timemodified = timecreated'));
    }
    if ($result && $oldversion < 2007112200) {
        /// Define table dialogue_read to be created
        $table = new XMLDBTable('dialogue_read');
        /// Adding fields to table dialogue_read
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('entryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('firstread', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('lastread', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table dialogue_read
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('dialogueread_entryid_userid_uk', XMLDB_KEY_UNIQUE, array('entryid', 'userid'));
        /// Launch create table for dialogue_read
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2007112201) {
        /// Define field conversationid to be added to dialogue_read
        $table = new XMLDBTable('dialogue_read');
        $field = new XMLDBField('conversationid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null, 'lastread');
        /// Launch add field conversationid
        $result = $result && add_field($table, $field);
        /// Define key dialogueread_conversation_fk (foreign) to be added to dialogue_read
        $table = new XMLDBTable('dialogue_read');
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:upgrade.php


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