當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLDBTable::add_key方法代碼示例

本文整理匯總了PHP中XMLDBTable::add_key方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLDBTable::add_key方法的具體用法?PHP XMLDBTable::add_key怎麽用?PHP XMLDBTable::add_key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XMLDBTable的用法示例。


在下文中一共展示了XMLDBTable::add_key方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: xmldb_assignment_team_upgrade

function xmldb_assignment_team_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2011013000) {
        //add table 'assignment_team'
        $table1 = new XMLDBTable('assignment_team');
        $table1->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'assignment');
        $table1->add_field('assignment', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'id', 'name');
        $table1->add_field('name', XMLDB_TYPE_CHAR, '100', XMLDB_NOTNULL, XMLDB_SEQUENCE, 'assignment', 'membershipopen');
        $table1->add_field('membershipopen', XMLDB_TYPE_INTEGER, '1', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'name', 'timemodified');
        $table1->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'membershipopen');
        $table1->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table1->add_key('assignment', XMLDB_KEY_FOREIGN, array('assignment'));
        if (!$dbman->table_exists($table1)) {
            $dbman->create_table($table1);
        }
        //add table 'assignment_team_student'
        $table2 = new XMLDBTable('assignment_team_student');
        $table2->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'true');
        $table2->add_field('student', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'id', 'team');
        $table2->add_field('team', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'student', 'timemodified');
        $table2->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'team');
        $table2->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table2->add_key('student', XMLDB_KEY_FOREIGN, array('student'));
        $table2->add_key('team', XMLDB_KEY_FOREIGN, array('team'));
        $table2->add_index('student-team', XMLDB_INDEX_UNIQUE, array('student', 'team'));
        if (!$dbman->table_exists($table2)) {
            $dbman->create_table($table2);
        }
        upgrade_plugin_savepoint(true, 2011013000, 'assignment', 'team');
    }
    return true;
}
開發者ID:nadavkav,項目名稱:Moodle2-Hebrew-plugins,代碼行數:34,代碼來源:upgrade.php


注:本文中的XMLDBTable::add_key方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。