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


PHP add_field函数代码示例

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


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

示例1: xmldb_groupselect_upgrade

function xmldb_groupselect_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2009020600) {
        /// Define field signuptype to be added to groupselect
        $table = new XMLDBTable('groupselect');
        $field = new XMLDBField('signuptype');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro');
        $result = $result && add_field($table, $field);
        /// Define field timecreated to be added to groupselect
        $table = new XMLDBTable('groupselect');
        $field = new XMLDBField('timecreated');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timedue');
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2009030500) {
        /// Define field targetgrouping to be added to groupselect
        $table = new XMLDBTable('groupselect');
        $field = new XMLDBField('targetgrouping');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
        $result = $result && add_field($table, $field);
    }
    return $result;
}
开发者ID:rwijaya,项目名称:moodle-mod_groupselect,代码行数:25,代码来源:upgrade.php

示例2: xmldb_wwassignment_upgrade

function xmldb_wwassignment_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 ======//
    if ($result && $oldversion < 2008092818) {
        //Define field grade to be added to wwassignment
        $table = new XMLDBTable('wwassignment');
        $field = new XMLDBField('grade');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'webwork_set');
        /// Launch add field grade
        $result = $result && add_field($table, $field);
        /// Define field timemodified to be added to wwassignment
        $table = new XMLDBTable('wwassignment');
        $field = new XMLDBField('timemodified');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'grade');
        /// Launch add field timemodified to wwassignment_bridge
        $result = $result && add_field($table, $field);
        //notify('Processing assignment grades, this may take a while if there are many assignments...', 'notifysuccess');
        // change grade typo to text if no grades MDL-13920
        //require_once $CFG->dirroot.'/mod/wwassignment/lib.php';
        // too much debug output
        //$db->debug = false;
        //wwassignment_update_grades();
        //$db->debug = true;
    }
    return $result;
}
开发者ID:bjornbe,项目名称:wwassignment,代码行数:35,代码来源:upgrade.php

示例3: xmldb_ilptarget_upgrade

function xmldb_ilptarget_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2008052906) {
        /// Define field name to be added to ilptarget_posts
        $table = new XMLDBTable('ilptarget_posts');
        $field = new XMLDBField('name');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'data2');
        /// Launch add field name
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2008052904) {
        /// Define field courserelated to be added to ilptarget_posts
        $table = new XMLDBTable('ilptarget_posts');
        $field = new XMLDBField('courserelated');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'course');
        /// Launch add field courserelated
        $result = $result && add_field($table, $field);
        $field = new XMLDBField('targetcourse');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courserelated');
        /// Launch add field targetcourse
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2008052902) {
        /// Define field course to be added to ilptarget_posts
        $table = new XMLDBTable('ilptarget_posts');
        $field = new XMLDBField('course');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'setbyuserid');
        /// Launch add field course
        $result = $result && add_field($table, $field);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:34,代码来源:upgrade.php

示例4: xmldb_block_file_manager_upgrade

function xmldb_block_file_manager_upgrade($oldversion = 0)
{
    /// This function does anything necessary to upgrade
    /// older versions to match current functionality
    $result = true;
    if ($result && $oldversion < 2008061700) {
        /// Define field ownertype to be added to fmanager_link
        $table = new XMLDBTable('fmanager_link');
        $field = new XMLDBField('ownertype');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner');
        /// Launch add field ownertype
        $result = $result && add_field($table, $field);
        /// Define field ownertype to be added to fmanager_categories
        $table = new XMLDBTable('fmanager_categories');
        $field = new XMLDBField('ownertype');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner');
        /// Launch add field ownertype
        $result = $result && add_field($table, $field);
        /// Define field ownertype to be added to fmanager_folders
        $table = new XMLDBTable('fmanager_folders');
        $field = new XMLDBField('ownertype');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner');
        /// Launch add field ownertype
        $result = $result && add_field($table, $field);
        /// Define field ownertype to be added to fmanager_shared
        $table = new XMLDBTable('fmanager_shared');
        $field = new XMLDBField('ownertype');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner');
        /// Launch add field ownertype
        $result = $result && add_field($table, $field);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:33,代码来源:upgrade.php

示例5: xmldb_artefact_resume_upgrade

function xmldb_artefact_resume_upgrade($oldversion = 0)
{
    $status = true;
    if ($oldversion < 2009122100) {
        $table = new XMLDBTable('artefact_resume_employmenthistory');
        $field = new XMLDBField('employeraddress');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);
        $table = new XMLDBTable('artefact_resume_educationhistory');
        $field = new XMLDBField('institutionaddress');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);
    }
    if ($oldversion < 2010020300) {
        $table = new XMLDBTable('artefact_resume_educationhistory');
        $field = new XMLDBField('qualtype');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        change_field_notnull($table, $field);
        $table = new XMLDBTable('artefact_resume_educationhistory');
        $field = new XMLDBField('qualname');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        change_field_notnull($table, $field);
    }
    if ($oldversion < 2013071300) {
        $table = new XMLDBTable('artefact_resume_book');
        $field = new XMLDBField('url');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);
    }
    if ($oldversion < 2013072900) {
        execute_sql("UPDATE {blocktype_installed_category} SET category = 'internal' WHERE category = 'resume'");
    }
    return $status;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:34,代码来源:upgrade.php

示例6: xmldb_ilpconcern_upgrade

function xmldb_ilpconcern_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    /// And upgrade begins here. For each one, you'll need one
    if ($result && $oldversion < 2008072501) {
        /// Define field courserelated to be added to ilptarget_posts
        $table = new XMLDBTable('ilpconcern_posts');
        $field = new XMLDBField('courserelated');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'course');
        /// Launch add field courserelated
        $result = $result && add_field($table, $field);
        $field = new XMLDBField('targetcourse');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courserelated');
        /// Launch add field targetcourse
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2008072200) {
        /// Define field course to be added to ilptarget_posts
        $table = new XMLDBTable('ilpconcern_status');
        $field = new XMLDBField('modifiedbyuser');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'modified');
        /// Launch add field course
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2008052800) {
        /// Define field course to be added to ilptarget_posts
        $table = new XMLDBTable('ilpconcern_posts');
        $field = new XMLDBField('course');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'setbyuserid');
        /// Launch add field course
        $result = $result && add_field($table, $field);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:35,代码来源:upgrade.php

示例7: xmldb_artefact_comment_upgrade

function xmldb_artefact_comment_upgrade($oldversion = 0)
{
    $success = true;
    if ($oldversion < 2011011201) {
        $table = new XMLDBTable('artefact_comment_comment');
        $field = new XMLDBField('rating');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED);
        $success = $success && add_field($table, $field);
    }
    if ($oldversion < 2013072400) {
        $table = new XMLDBTable('artefact_comment_comment');
        $field = new XMLDBField('lastcontentupdate');
        $field->setAttributes(XMLDB_TYPE_DATETIME);
        $success = $success && add_field($table, $field);
        $success = $success && execute_sql('update {artefact_comment_comment} acc
            set lastcontentupdate = (
                select a.mtime
                from {artefact} a
                where a.id = acc.artefact
            )');
    }
    if ($oldversion < 2015081000) {
        // Set default maxindent for threaded comments
        set_config_plugin('artefact', 'comment', 'maxindent', 5);
    }
    return $success;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:27,代码来源:upgrade.php

示例8: xmldb_block_task_list_upgrade

function xmldb_block_task_list_upgrade($oldversion = 0)
{
    $result = true;
    if ($result and $oldversion < 2007011501) {
        /// Define field format to be added to block_task_list
        $table = new XMLDBTable('block_task_list');
        $field = new XMLDBField('format');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'name');
        /// Launch add field format
        $result = $result and add_field($table, $field);
    }
    if ($result and $oldversion < 2007011503) {
        /// Manually remove bad capabilities
        $result = $result and delete_records('capabilities', 'name', 'block/tast_list:manage');
        $result = $result and delete_records('capabilities', 'name', 'block/tast_list:checkofftasks');
    }
    if ($result and $oldversion < 2007011505) {
        //TODO: The info field might be able to be removed, as it doesn't seem to be used anywhere, but in the meantime, change it to allow nulls
        /// Changing nullability of field info on table block_task_list to allow null
        $table = new XMLDBTable('block_task_list');
        $field = new XMLDBField('info');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'checked');
        /// Launch change of nullability for field info
        $result = $result && change_field_notnull($table, $field);
    }
    return $result;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:27,代码来源:upgrade.php

示例9: xmldb_block_accessibility_upgrade

function xmldb_block_accessibility_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 < 2009082500) {
        /// Define field colourscheme to be added to accessibility
        $table = new XMLDBTable('accessibility');
        $field = new XMLDBField('colourscheme');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null, 'fontsize');
        /// Launch add field colourscheme
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2009071000) {
        /// Changing type of field fontsize on table accessibility to number
        $table = new XMLDBTable('accessibility');
        $field = new XMLDBField('fontsize');
        $field->setAttributes(XMLDB_TYPE_NUMBER, '4, 1', XMLDB_UNSIGNED, null, null, null, null, null, 'userid');
        /// Launch change of type for field fontsize
        $result = $result && change_field_type($table, $field);
    }
    return $result;
}
开发者ID:henriquecrang,项目名称:e-UNI,代码行数:26,代码来源:upgrade.php

示例10: xmldb_report_customsql_upgrade

/**
 * Database upgrade script for the custom SQL report.
 *
 * @package report_customsql
 * @copyright 2009 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_report_customsql_upgrade($oldversion = 0)
{
    global $CFG, $db;
    $result = true;
    if ($result && $oldversion < 2009102802) {
        /// Define field runable to be added to report_customsql_queries
        $table = new XMLDBTable('report_customsql_queries');
        $field = new XMLDBField('runable');
        $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'manual', 'lastexecutiontime');
        /// Launch add field runable
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2009102900) {
        /// Define field singlerow to be added to report_customsql_queries
        $table = new XMLDBTable('report_customsql_queries');
        $field = new XMLDBField('singlerow');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'runable');
        /// Launch add field singlerow
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2009103000) {
        /// Changing the default of field lastrun on table report_customsql_queries to 0
        $table = new XMLDBTable('report_customsql_queries');
        $field = new XMLDBField('lastrun');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'capability');
        /// Launch change of default for field lastrun
        $result = $result && change_field_default($table, $field);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:37,代码来源:upgrade.php

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

示例12: xmldb_qtype_dragdrop_upgrade

function xmldb_qtype_dragdrop_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
    /// }
    // Add a field so that question authors can choose  in how many columns
    // the drag and drop media is arranged.
    if ($result && $oldversion < 2008060501) {
        $table = new XMLDBTable('question_dragdrop');
        $field = new XMLDBField('arrangemedia');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'feedbackmissed');
        $result = $result && add_field($table, $field);
    }
    // Add a field so that question authors can choose where to place the media
    // below or right beside the background.
    if ($result && $oldversion < 2008060502) {
        $table = new XMLDBTable('question_dragdrop');
        $field = new XMLDBField('placemedia');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'arrangemedia');
        $result = $result && add_field($table, $field);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:29,代码来源:upgrade.php

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

示例14: xmldb_interaction_forum_upgrade

function xmldb_interaction_forum_upgrade($oldversion = 0)
{
    if ($oldversion < 2009062300) {
        foreach (array('topic', 'forum') as $type) {
            log_debug("Subscription upgrade for {$type}s");
            // Add missing primary key to the subscription tables
            // Step 1: remove duplicates
            if ($dupes = get_records_sql_array('
                SELECT "user", ' . $type . ', COUNT(*)
                FROM {interaction_forum_subscription_' . $type . '}
                GROUP BY "user", ' . $type . '
                HAVING COUNT(*) > 1', array())) {
                // We found duplicate subscriptions to a topic/forum
                foreach ($dupes as $dupe) {
                    log_debug("interaction.forum: Removing duplicate {$type} subscription for {$dupe->user}");
                    delete_records('interaction_forum_subscription_' . $type, 'user', $dupe->user, $type, $dupe->{$type});
                    insert_record('interaction_forum_subscription_' . $type, (object) array('user' => $dupe->user, $type => $dupe->{$type}));
                }
            }
            // Step 2: add the actual key
            $table = new XMLDBTable('interaction_forum_subscription_' . $type);
            $key = new XMLDBKey('primary');
            $key->setAttributes(XMLDB_KEY_PRIMARY, array('user', $type));
            add_key($table, $key);
            // Add a 'key' column, used for unsubscriptions
            $field = new XMLDBField('key');
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, null);
            add_field($table, $field);
            $key = new XMLDBKey('keyuk');
            $key->setAttributes(XMLDB_KEY_UNIQUE, array('key'));
            add_key($table, $key);
            // Populate the key column
            if ($records = get_records_array('interaction_forum_subscription_' . $type, '', '', '', '"user", ' . $type)) {
                foreach ($records as $where) {
                    $new = (object) array('user' => $where->user, $type => $where->{$type}, 'key' => dechex(mt_rand()));
                    update_record('interaction_forum_subscription_' . $type, $new, $where);
                }
            }
            // Now make the key column not null
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, XMLDB_NOTNULL);
            change_field_notnull($table, $field);
        }
    }
    if ($oldversion < 2009081700) {
        if (!get_record('interaction_config', 'plugin', 'forum', 'field', 'postdelay')) {
            insert_record('interaction_config', (object) array('plugin' => 'forum', 'field' => 'postdelay', 'value' => 30));
        }
    }
    if ($oldversion < 2009081800) {
        $subscription = (object) array('plugin' => 'forum', 'event' => 'creategroup', 'callfunction' => 'create_default_forum');
        ensure_record_exists('interaction_event_subscription', $subscription, $subscription);
    }
    return true;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:54,代码来源:upgrade.php

示例15: wrsqz_update_table

/**
 * Checks all fields of table and adds the missing ones. 
 **/
function wrsqz_update_table(&$table)
{
    $result = TABLE_EXISTS;
    foreach ($table->fields as $field) {
        if (!field_exists($table, $field)) {
            add_field($table, $field, true, true);
            $result = TABLE_UPDATED;
        }
    }
    return $result;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:14,代码来源:db.php


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