本文整理汇总了PHP中XMLDBTable::add_field方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBTable::add_field方法的具体用法?PHP XMLDBTable::add_field怎么用?PHP XMLDBTable::add_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDBTable
的用法示例。
在下文中一共展示了XMLDBTable::add_field方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: xmldb_attforblock_upgrade
function xmldb_attforblock_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 < 2008021904) {
//New version in version.php
global $USER;
if ($sessions = $DB->get_records('attendance_sessions', array('takenby' => 0))) {
foreach ($sessions as $sess) {
if ($DB->count_records('attendance_log', array('attsid' => $sess->id)) > 0) {
$sess->takenby = $USER->id;
$sess->timetaken = $sess->timemodified ? $sess->timemodified : time();
$sess->description = addslashes($sess->description);
$result = $DB->update_record('attendance_sessions', $sess) and $result;
}
}
}
}
if ($oldversion < 2008102401 and $result) {
$table = new XMLDBTable('attforblock');
$field = new XMLDBField('grade');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '100', 'name');
$result = $result && $table->add_field($table, $field);
$table = new XMLDBTable('attendance_sessions');
$field = new XMLDBField('courseid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$result = $result && $table->change_field_unsigned($table, $field);
// $field = new XMLDBField('creator');
// $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courseid');
// $result = $result && change_field_unsigned($table, $field);
$field = new XMLDBField('sessdate');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'creator');
$result = $result && change_field_unsigned($table, $field);
$field = new XMLDBField('duration');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'sessdate');
$result = $result && add_field($table, $field);
$field = new XMLDBField('timetaken');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'takenby');
$result = $result && change_field_unsigned($table, $field);
$result = $result && rename_field($table, $field, 'lasttaken');
$field = new XMLDBField('takenby');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'lasttaken');
$result = $result && change_field_unsigned($table, $field);
$result = $result && rename_field($table, $field, 'lasttakenby');
$field = new XMLDBField('timemodified');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'lasttaken');
$result = $result && change_field_unsigned($table, $field);
$table = new XMLDBTable('attendance_log');
$field = new XMLDBField('attsid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$result = $result && change_field_unsigned($table, $field);
$field = new XMLDBField('studentid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'attsid');
$result = $result && change_field_unsigned($table, $field);
$field = new XMLDBField('statusid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'status');
$result = $result && add_field($table, $field);
$field = new XMLDBField('statusset');
$field->setAttributes(XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null, 'statusid');
$result = $result && add_field($table, $field);
$field = new XMLDBField('timetaken');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'statusid');
$result = $result && add_field($table, $field);
$field = new XMLDBField('takenby');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timetaken');
$result = $result && add_field($table, $field);
//Indexes
$index = new XMLDBIndex('statusid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('statusid'));
$result = $result && add_index($table, $index);
$index = new XMLDBIndex('attsid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('attsid'));
$result = $result && drop_index($table, $index);
$field = new XMLDBField('attsid');
//Rename field
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$result = $result && rename_field($table, $field, 'sessionid');
$index = new XMLDBIndex('sessionid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('sessionid'));
$result = $result && add_index($table, $index);
$table = new XMLDBTable('attendance_settings');
$field = new XMLDBField('courseid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$result = $result && change_field_unsigned($table, $field);
$field = new XMLDBField('visible');
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1', 'grade');
$result = $result && add_field($table, $field);
$field = new XMLDBField('deleted');
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'visible');
$result = $result && add_field($table, $field);
//Indexes
$index = new XMLDBIndex('visible');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('visible'));
$result = $result && add_index($table, $index);
$index = new XMLDBIndex('deleted');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('deleted'));
//.........这里部分代码省略.........