本文整理汇总了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;
}