本文整理汇总了PHP中xmldb_field类的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_field类的具体用法?PHP xmldb_field怎么用?PHP xmldb_field使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了xmldb_field类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_customlabel_upgrade
function xmldb_customlabel_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$result = true;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($result && $oldversion < 2012062401) {
// Define field fallbacktype to be added to customlabel.
$table = new xmldb_table('customlabel');
$field = new xmldb_field('fallbacktype');
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, 'labelclass');
// Launch add field parent.
$result = $result || $dbman->add_field($table, $field);
// customlabel savepoint reached.
upgrade_mod_savepoint($result, 2012062401, 'customlabel');
}
if ($result && $oldversion < 2013041802) {
// Regenerates all contents to match template changes.
$sql = "\n SELECT DISTINCT\n c.id,\n c.shortname,\n c.fullname,\n c.idnumber,\n c.summary,\n c.category,\n c.summaryformat\n FROM\n {course} c,\n {course_modules} cm,\n {modules} m\n WHERE\n c.id = cm.course AND\n cm.module = m.id AND\n m.name = 'customlabel'\n ";
$courses = $DB->get_records_sql($sql);
if ($courses) {
echo '<pre>';
foreach ($courses as $c) {
customlabel_course_preprocess_filepickers($c);
customlabel_course_regenerate($c, 'all');
}
echo '</pre>';
}
upgrade_mod_savepoint($result, 2013041802, 'customlabel');
}
return $result;
}
示例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_local_lae_install
function xmldb_local_lae_install()
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Migrate the old config setting, if present.
if (!empty($CFG->forum_anonymous)) {
set_config('forum_enableanonymousposts', $CFG->forum_anonymous);
set_config('forum_anonymous', null);
}
// Extend forum tables.
$table = new xmldb_table('forum');
$field = new xmldb_field('anonymous');
$field->set_attributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionposts');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$table = new xmldb_table('forum_posts');
$field = new xmldb_field('hiddenuserid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, 'mailnow');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Add anonymous user.
if (empty($CFG->anonymous_userid)) {
$anon_user = new stdClass();
$anon_user->username = 'anonymous_user';
// The password needs strings.
$anon_user->password = hash_internal_user_password(str_shuffle($anon_user->username) . (string) mt_rand());
$anon_user->auth = 'nologin';
$anon_user->firstname = get_string('auser_firstname', 'local_lae');
$anon_user->lastname = get_string('auser_lastname', 'local_lae');
$anon_user->mnethostid = $CFG->mnet_localhost_id;
$anon_user->email = get_string('auser_email', 'local_lae');
if ($result = $DB->insert_record('user', $anon_user)) {
set_config('anonymous_userid', $result);
context_user::instance($result);
} else {
print_error("Failed to create anonymous user");
return false;
}
}
// Update course table to support display defaults
$table = new xmldb_table('course');
$field = new xmldb_field('filedisplaydefault', XMLDB_TYPE_INTEGER, '2', null, null, null, null, null);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
return true;
}
示例4: xmldb_groupselect_upgrade
function xmldb_groupselect_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$result = true;
$dbman = $DB->get_manager();
if ($result && $oldversion < 2009020600) {
/// Define field signuptype to be added to groupselect
$table = new xmldb_table('groupselect');
$field = new xmldb_field('signuptype');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, '0', 'intro');
$dbman->add_field($table, $field);
/// Define field timecreated to be added to groupselect
$table = new xmldb_table('groupselect');
$field = new xmldb_field('timecreated');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timedue');
$dbman->add_field($table, $field);
}
if ($result && $oldversion < 2009030500) {
/// Define field targetgrouping to be added to groupselect
$table = new xmldb_table('groupselect');
$field = new xmldb_field('targetgrouping');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
$dbman->add_field($table, $field);
}
if ($result && $oldversion < 2009061200) {
$table = new xmldb_table('groupselect');
$field = new xmldb_field('individual_limits');
$field->set_attributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$dbman->add_field($table, $field);
$table = new xmldb_table('groupselect_limits');
if ($result && !$dbman->table_exists($table)) {
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->add_field('groupselect', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->add_field('lim', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_index('groupselect', XMLDB_INDEX_NOTUNIQUE, array('groupselect'));
$dbman->create_table($table);
}
}
// Define field introformat to be added to groupselect
if ($result && $oldversion < 2010101300) {
$table = new xmldb_table('groupselect');
$field = new xmldb_field('introformat');
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$dbman->add_field($table, $field);
}
return $result;
}
示例5: xmldb_block_poll_upgrade
function xmldb_block_poll_upgrade($oldversion)
{
global $DB;
$dbman = $DB->get_manager();
// Add a new column for anonymous polls.
if ($oldversion < 2011041400) {
$table = new xmldb_table('block_poll');
$field = new xmldb_field('anonymous');
$field->set_attributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'created');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}
return true;
}
示例6: invoke
/**
* Invoke method, every class will have its own
* returns true/false on completion, setting both
* errormsg and output as necessary
*/
function invoke()
{
parent::invoke();
$result = true;
// Set own core attributes
$this->does_generate = ACTION_NONE;
//$this->does_generate = ACTION_GENERATE_HTML;
// These are always here
global $CFG, $XMLDB;
// Do the job, setting result as needed
// Get the dir containing the file
$dirpath = required_param('dir', PARAM_PATH);
$dirpath = $CFG->dirroot . $dirpath;
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
$dbdir =& $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
$editeddir =& $XMLDB->editeddirs[$dirpath];
$structure =& $editeddir->xml_file->getStructure();
}
// If the changeme table exists, just get it and continue
$changeme_exists = false;
if ($tables =& $structure->getTables()) {
if ($table =& $structure->getTable('changeme')) {
$changeme_exists = true;
}
}
if (!$changeme_exists) {
// Lets create the table
$field = new xmldb_field('id');
$field->setType(XMLDB_TYPE_INTEGER);
$field->setLength(10);
$field->setNotNull(true);
$field->setUnsigned(true);
$field->setSequence(true);
$field->setLoaded(true);
$field->setChanged(true);
$key = new xmldb_key('primary');
$key->setType(XMLDB_KEY_PRIMARY);
$key->setFields(array('id'));
$key->setLoaded(true);
$key->setChanged(true);
$table = new xmldb_table('changeme');
$table->setComment('Default comment for the table, please edit me');
$table->addField($field);
$table->addKey($key);
// Finally, add the whole retrofitted table to the structure
// in the place specified
$structure->addTable($table);
}
// Launch postaction if exists (leave this here!)
if ($this->getPostAction() && $result) {
return $this->launch($this->getPostAction());
}
// Return ok if arrived here
return $result;
}
示例7: xmldb_customlabel_upgrade
function xmldb_customlabel_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$result = true;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($result && $oldversion < 2012062401) {
/// Define field fallbacktype to be added to customlabel
$table = new xmldb_table('customlabel');
$field = new xmldb_field('fallbacktype');
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, 'labelclass');
/// Launch add field parent
$result = $result || $dbman->add_field($table, $field);
/// customlabel savepoint reached
upgrade_mod_savepoint($result, 2012062401, 'customlabel');
}
return $result;
}
示例8: xmldb_engagement_upgrade
/**
* Upgrades for engagement
*
* @package mod_engagement
* @copyright 2012 NetSpot Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_engagement_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2012061900) {
if (!$dbman->table_exists('engagement_cache')) {
$dbman->install_one_table_from_xmldb_file($CFG->dirroot . '/mod/engagement/db/install.xml', 'engagement_cache');
}
upgrade_mod_savepoint(true, 2012061900, 'engagement');
}
if ($oldversion < 2012080700) {
$table = new xmldb_table('engagement_cache');
$field = new xmldb_field('rawdata');
$field->set_attributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field, 'settings');
}
upgrade_mod_savepoint(true, 2012080700, 'engagement');
}
return true;
}
示例9: xmldb_conceptmap_upgrade
function xmldb_conceptmap_upgrade($oldversion = 0)
{
if ($oldversion < 20151231) {
// Add new fields to certificate table.
$table = new xmldb_table('concept-map');
$field = new xmldb_field('showcode');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'savecert');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Add new fields to certificate_issues table.
$table = new xmldb_table('certificate_issues');
$field = new xmldb_field('code');
$field->set_attributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, 'certificateid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Certificate savepoint reached.
upgrade_mod_savepoint(true, 2012091800, 'certificate');
}
}
示例10: xmldb_groupreg_upgrade
function xmldb_groupreg_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
if ($oldversion < 2011100201) {
$table = new xmldb_table('groupreg');
$field = new xmldb_field('groupmembers');
$field->set_attributes(XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '4', 'assigned');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}
if ($oldversion < 2011112601) {
// Adding DB field: boolean (int-1) "finalized", telling whether the students have already been put in their groups.
$table = new xmldb_table('groupreg');
$field = new xmldb_field('finalized');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupmembers');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}
return true;
}
示例11: xmldb_mindmap_upgrade
/**
* Mindmap plugin upgrade code
*
* @package mod
* @subpackage mindmap
* @author ekpenso.com
* @copyright 2011 Tõnis Tartes <tonis.tartes@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_mindmap_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
/// loads ddl manager and xmldb classes
$result = true;
if ($oldversion < 2012032300) {
upgrade_mod_savepoint(true, 2012032300, 'mindmap');
}
if ($oldversion < 2012061300) {
$table = new xmldb_table('mindmap');
$field = new xmldb_field('editable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'userid');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2012061300, 'mindmap');
}
if ($oldversion < 2012070400) {
upgrade_mod_savepoint(true, 2012070400, 'mindmap');
}
//Locking functionality
if ($oldversion < 2013030100) {
$table = new xmldb_table('mindmap');
$field = new xmldb_field('locking');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'timemodified');
$dbman->add_field($table, $field);
$table = new xmldb_table('mindmap');
$field = new xmldb_field('locked');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'locking');
$dbman->add_field($table, $field);
$table = new xmldb_table('mindmap');
$field = new xmldb_field('lockedbyuser');
$field->set_attributes(XMLDB_TYPE_INTEGER, '12', null, XMLDB_NOTNULL, null, '0', 'locked');
$dbman->add_field($table, $field);
upgrade_mod_savepoint(true, 2013030100, 'mindmap');
}
return $result;
}
示例12: getRenameTableExtraSQL
/**
* Returns the code (array of statements) needed to execute extra statements on table rename
*/
public function getRenameTableExtraSQL($xmldb_table, $newname)
{
$results = array();
$xmldb_field = new xmldb_field('id');
// Fields having sequences should be exclusively, id.
$oldseqname = $this->getSequenceFromDB($xmldb_table);
$newseqname = $this->getNameForObject($newname, $xmldb_field->getName(), 'seq');
/// Rename de sequence
$results[] = 'RENAME ' . $oldseqname . ' TO ' . $newseqname;
$oldtriggername = $this->getTriggerFromDB($xmldb_table);
$newtriggername = $this->getNameForObject($newname, $xmldb_field->getName(), 'trg');
/// Drop old trigger
$results[] = "DROP TRIGGER " . $oldtriggername;
$newt = new xmldb_table($newname);
/// Temp table for trigger code generation
/// Create new trigger
$results = array_merge($results, $this->getCreateTriggerSQL($newt, $xmldb_field));
/// Rename all the check constraints in the table
$oldtablename = $this->getTableName($xmldb_table);
$newtablename = $this->getTableName($newt);
$oldconstraintprefix = $this->getNameForObject($xmldb_table->getName(), '');
$newconstraintprefix = $this->getNameForObject($newt->getName(), '', '');
if ($constraints = $this->getCheckConstraintsFromDB($xmldb_table)) {
foreach ($constraints as $constraint) {
/// Drop the old constraint
$results[] = 'ALTER TABLE ' . $newtablename . ' DROP CONSTRAINT ' . $constraint->name;
}
}
return $results;
}
示例13: arr2xmldb_table
/**
* Load data from XML to the table
*/
function arr2xmldb_table($xmlarr)
{
global $CFG;
$result = true;
/// Debug the table
/// traverse_xmlize($xmlarr); //Debug
/// print_object ($GLOBALS['traverse_array']); //Debug
/// $GLOBALS['traverse_array']=""; //Debug
/// Process table attributes (name, comment, previoustable and nexttable)
if (isset($xmlarr['@']['NAME'])) {
$this->name = trim($xmlarr['@']['NAME']);
} else {
$this->errormsg = 'Missing NAME attribute';
$this->debug($this->errormsg);
$result = false;
}
if (isset($xmlarr['@']['COMMENT'])) {
$this->comment = trim($xmlarr['@']['COMMENT']);
} else {
if (!empty($CFG->xmldbdisablecommentchecking)) {
$this->comment = '';
} else {
$this->errormsg = 'Missing COMMENT attribute';
$this->debug($this->errormsg);
$result = false;
}
}
if (isset($xmlarr['@']['PREVIOUS'])) {
$this->previous = trim($xmlarr['@']['PREVIOUS']);
}
if (isset($xmlarr['@']['NEXT'])) {
$this->next = trim($xmlarr['@']['NEXT']);
}
/// Iterate over fields
if (isset($xmlarr['#']['FIELDS']['0']['#']['FIELD'])) {
foreach ($xmlarr['#']['FIELDS']['0']['#']['FIELD'] as $xmlfield) {
if (!$result) {
//Skip on error
continue;
}
$name = trim($xmlfield['@']['NAME']);
$field = new xmldb_field($name);
$field->arr2xmldb_field($xmlfield);
$this->fields[] = $field;
if (!$field->isLoaded()) {
$this->errormsg = 'Problem loading field ' . $name;
$this->debug($this->errormsg);
$result = false;
}
}
} else {
$this->errormsg = 'Missing FIELDS section';
$this->debug($this->errormsg);
$result = false;
}
/// Perform some general checks over fields
if ($result && $this->fields) {
/// Check field names are ok (lowercase, a-z _-)
if (!$this->checkNameValues($this->fields)) {
$this->errormsg = 'Some FIELDS name values are incorrect';
$this->debug($this->errormsg);
$result = false;
}
/// Check previous & next are ok (duplicates and existing fields)
$this->fixPrevNext($this->fields);
if ($result && !$this->checkPreviousNextValues($this->fields)) {
$this->errormsg = 'Some FIELDS previous/next values are incorrect';
$this->debug($this->errormsg);
$result = false;
}
/// Order fields
if ($result && !$this->orderFields($this->fields)) {
$this->errormsg = 'Error ordering the fields';
$this->debug($this->errormsg);
$result = false;
}
}
/// Iterate over keys
if (isset($xmlarr['#']['KEYS']['0']['#']['KEY'])) {
foreach ($xmlarr['#']['KEYS']['0']['#']['KEY'] as $xmlkey) {
if (!$result) {
//Skip on error
continue;
}
$name = trim($xmlkey['@']['NAME']);
$key = new xmldb_key($name);
$key->arr2xmldb_key($xmlkey);
$this->keys[] = $key;
if (!$key->isLoaded()) {
$this->errormsg = 'Problem loading key ' . $name;
$this->debug($this->errormsg);
$result = false;
}
}
} else {
$this->errormsg = 'Missing KEYS section (at least one PK must exist)';
$this->debug($this->errormsg);
//.........这里部分代码省略.........
示例14: xmldb_offlinequiz_upgrade
function xmldb_offlinequiz_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB, $OUTPUT;
$dbman = $DB->get_manager();
// 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.
// ONLY UPGRADE FROM Moodle 1.9.x (module version 2009042100) is supported.
if ($oldversion < 2009120700) {
// Define field counter to be added to offlinequiz_i_log.
$table = new xmldb_table('offlinequiz_i_log');
$field = new xmldb_field('counter');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'rawdata');
// Launch add field counter.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field corners to be added to offlinequiz_i_log.
$field = new xmldb_field('corners');
$field->set_attributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, 'counter');
// Launch add field corners.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field pdfintro to be added to offlinequiz.
$table = new xmldb_table('offlinequiz');
$field = new xmldb_field('pdfintro');
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'intro');
// Launch add field pdfintro.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Offlinequiz savepoint reached.
upgrade_mod_savepoint(true, 2009120700, 'offlinequiz');
}
if ($oldversion < 2010082900) {
// Define table offlinequiz_p_list to be created.
$table = new xmldb_table('offlinequiz_p_list');
// Adding fields to table offlinequiz_p_list.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('offlinequiz', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->add_field('list', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
// Adding keys to table offlinequiz_p_list.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Launch create table for offlinequiz_p_list.
$dbman->create_table($table);
// Define field position to be dropped from offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$field = new xmldb_field('position');
// Launch drop field position.
$dbman->drop_field($table, $field);
// Define field page to be dropped from offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$field = new xmldb_field('page');
// Launch drop field page.
$dbman->drop_field($table, $field);
// Define field list to be added to offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$field = new xmldb_field('list');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'userid');
// Launch add field list.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Offlinequiz savepoint reached.
upgrade_mod_savepoint(true, 2010082900, 'offlinequiz');
}
if ($oldversion < 2010090600) {
// Define index offlinequiz (not unique) to be added to offlinequiz_p_list.
$table = new xmldb_table('offlinequiz_p_list');
$index = new XMLDBIndex('offlinequiz');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('offlinequiz'));
// Launch add index offlinequiz.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$index = new XMLDBIndex('list');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('list'));
// Launch add index list.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Define index offlinequiz (not unique) to be added to offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$index = new XMLDBIndex('offlinequiz');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('offlinequiz'));
// Launch add index offlinequiz.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$index = new XMLDBIndex('list');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('list'));
// Launch add index list.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$index = new XMLDBIndex('userid');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
//.........这里部分代码省略.........
示例15: xmldb_main_upgrade
//.........这里部分代码省略.........
upgrade_main_savepoint(true, 2008050100);
}
if ($oldversion < 2008050200) {
// remove unused config options
unset_config('statsrolesupgraded');
upgrade_main_savepoint(true, 2008050200);
}
if ($oldversion < 2008050700) {
upgrade_set_timeout(60 * 20);
// this may take a while
/// Fix minor problem caused by MDL-5482.
require_once $CFG->dirroot . '/question/upgrade.php';
question_fix_random_question_parents();
upgrade_main_savepoint(true, 2008050700);
}
if ($oldversion < 2008051201) {
echo $OUTPUT->notification('Increasing size of user idnumber field, this may take a while...', 'notifysuccess');
upgrade_set_timeout(60 * 20);
// this may take a while
/// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859
$dbfamily = $DB->get_dbfamily();
if ($dbfamily === 'mysql' || $dbfamily === 'postgres') {
$DB->execute("UPDATE {user} SET idnumber = '' WHERE idnumber IS NULL");
}
/// Define index idnumber (not unique) to be dropped form user
$table = new xmldb_table('user');
$index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
/// Launch drop index idnumber
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
/// Changing precision of field idnumber on table user to (255)
$table = new xmldb_table('user');
$field = new xmldb_field('idnumber', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'password');
/// Launch change of precision for field idnumber
$dbman->change_field_precision($table, $field);
/// Launch add index idnumber again
$index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
$dbman->add_index($table, $index);
/// Main savepoint reached
upgrade_main_savepoint(true, 2008051201);
}
if ($oldversion < 2008051203) {
$table = new xmldb_table('mnet_enrol_course');
$field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0);
$dbman->change_field_precision($table, $field);
upgrade_main_savepoint(true, 2008051203);
}
if ($oldversion < 2008063001) {
upgrade_set_timeout(60 * 20);
// this may take a while
// table to be modified
$table = new xmldb_table('tag_instance');
// add field
$field = new xmldb_field('tiuserid');
if (!$dbman->field_exists($table, $field)) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'itemid');
$dbman->add_field($table, $field);
}
// modify index
$index = new xmldb_index('itemtype-itemid-tagid');
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid'));
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
$index = new xmldb_index('itemtype-itemid-tagid-tiuserid');