本文整理汇总了PHP中xmldb_index类的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_index类的具体用法?PHP xmldb_index怎么用?PHP xmldb_index使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了xmldb_index类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDropIndex
public function testDropIndex()
{
$DB = $this->tdb;
// Do not use global $DB!
$dbman = $this->tdb->get_manager();
$table = $this->create_deftable('test_table1');
$index = new xmldb_index('secondname');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$dbman->add_index($table, $index);
$dbman->drop_index($table, $index);
$this->assertFalse($dbman->find_index_name($table, $index));
// Test we are able to drop indexes having hyphens MDL-22804.
// Create index with hyphens (by hand).
$indexname = 'test-index-with-hyphens';
switch ($DB->get_dbfamily()) {
case 'mysql':
$indexname = '`' . $indexname . '`';
break;
default:
$indexname = '"' . $indexname . '"';
}
$stmt = "CREATE INDEX {$indexname} ON {$DB->get_prefix()}test_table1 (course, name)";
$DB->change_database_structure($stmt);
$this->assertNotEmpty($dbman->find_index_name($table, $index));
// Index created, let's drop it using db manager stuff.
$index = new xmldb_index('indexname', XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$dbman->drop_index($table, $index);
$this->assertFalse($dbman->find_index_name($table, $index));
}
示例2: check_table
protected function check_table(xmldb_table $xmldb_table, array $metacolumns)
{
global $DB;
$dbman = $DB->get_manager();
$o = '';
$missing_indexes = array();
// Keys
if ($xmldb_keys = $xmldb_table->getKeys()) {
$o .= ' <ul>';
foreach ($xmldb_keys as $xmldb_key) {
$o .= ' <li>' . $this->str['key'] . ': ' . $xmldb_key->readableInfo() . ' ';
// Primaries are skipped
if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) {
$o .= '<font color="green">' . $this->str['ok'] . '</font></li>';
continue;
}
// If we aren't creating the keys or the key is a XMLDB_KEY_FOREIGN (not underlying index generated
// automatically by the RDBMS) create the underlying (created by us) index (if doesn't exists)
if (!$dbman->generator->getKeySQL($xmldb_table, $xmldb_key) || $xmldb_key->getType() == XMLDB_KEY_FOREIGN) {
// Create the interim index
$xmldb_index = new xmldb_index('anyname');
$xmldb_index->setFields($xmldb_key->getFields());
switch ($xmldb_key->getType()) {
case XMLDB_KEY_UNIQUE:
case XMLDB_KEY_FOREIGN_UNIQUE:
$xmldb_index->setUnique(true);
break;
case XMLDB_KEY_FOREIGN:
$xmldb_index->setUnique(false);
break;
}
// Check if the index exists in DB
if ($dbman->index_exists($xmldb_table, $xmldb_index)) {
$o .= '<font color="green">' . $this->str['ok'] . '</font>';
} else {
$o .= '<font color="red">' . $this->str['missing'] . '</font>';
// Add the missing index to the list
$obj = new stdClass();
$obj->table = $xmldb_table;
$obj->index = $xmldb_index;
$missing_indexes[] = $obj;
}
}
$o .= '</li>';
}
$o .= ' </ul>';
}
// Indexes
if ($xmldb_indexes = $xmldb_table->getIndexes()) {
$o .= ' <ul>';
foreach ($xmldb_indexes as $xmldb_index) {
$o .= ' <li>' . $this->str['index'] . ': ' . $xmldb_index->readableInfo() . ' ';
// Check if the index exists in DB
if ($dbman->index_exists($xmldb_table, $xmldb_index)) {
$o .= '<font color="green">' . $this->str['ok'] . '</font>';
} else {
$o .= '<font color="red">' . $this->str['missing'] . '</font>';
// Add the missing index to the list
$obj = new stdClass();
$obj->table = $xmldb_table;
$obj->index = $xmldb_index;
$missing_indexes[] = $obj;
}
$o .= '</li>';
}
$o .= ' </ul>';
}
return array($o, $missing_indexes);
}
示例3: xmldb_block_helpmenow_upgrade
//.........这里部分代码省略.........
$table->add_field('details', XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table block_helpmenow_error_log
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Launch create table for block_helpmenow_error_log
$result = $result && $dbman->create_table($table);
}
if ($result && $oldversion < 2012123100) {
/// Define field userid to be added to block_helpmenow_error_log
$table = new xmldb_table('block_helpmenow_error_log');
$field = new xmldb_field('userid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null, 'timecreated');
/// Launch add field userid
$result = $result && $dbman->add_field($table, $field);
}
if ($result && $oldversion < 2013011800) {
/// Define table block_helpmenow_contact to be created
$table = new xmldb_table('block_helpmenow_contact');
/// Adding fields to table block_helpmenow_contact
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('contact_userid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table block_helpmenow_contact
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table block_helpmenow_contact
$table->add_index('block_helpmenow_contact_userid_ix', XMLDB_INDEX_NOTUNIQUE, array('userid'));
/// Launch create table for block_helpmenow_contact
$result = $result && $dbman->create_table($table);
}
if ($result && $oldversion < 2013050200) {
/// Define index block_helpmenow_log_u_ix (not unique) to be added to block_helpmenow_log
$table = new xmldb_table('block_helpmenow_log');
$index = new xmldb_index('block_helpmenow_log_u_ix');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
/// Launch add index block_helpmenow_log_u_ix
$result = $result && $dbman->add_index($table, $index);
/// Define index block_helpmenow_log_ua_ix (not unique) to be added to block_helpmenow_log
$table = new xmldb_table('block_helpmenow_log');
$index = new xmldb_index('block_helpmenow_log_ua_ix');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('userid', 'action'));
/// Launch add index block_helpmenow_log_ua_ix
$result = $result && $dbman->add_index($table, $index);
}
if ($result && $oldversion < 2013050700) {
/// Define field last_read to be added to block_helpmenow_session2user
$table = new xmldb_table('block_helpmenow_session2user');
$field = new xmldb_field('last_read');
$field->set_attributes(XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, '0', 'cache');
/// Launch add field last_read
$result = $result && $dbman->add_field($table, $field);
}
if ($result && $oldversion < 2014050401) {
// Reminder: do not use core/lib function in upgrade script!
$contextid = $DB->get_field('context', 'id', array('contextlevel' => CONTEXT_SYSTEM));
// Hardcode the capability as they must match the value at this upgrade time.
$HELPMENOW_CAP_QUEUE_ANSWER = 'block/helpmenow:global_queue_answer';
$HELPMENOW_CAP_QUEUE_ASK = 'block/helpmenow:queue_ask';
$HELPMENOW_CAP_MANAGE = 'block/helpmenow:manage_queues';
// Add Help Me Now block manager system role.
$role = new stdClass();
$role->name = 'Help Me Now Manager';
$role->shortname = 'helpmenowmanager';
$role->description = 'can assign a queue helper - can do anything on helpmenow.';
// Find free sortorder number.
$role->sortorder = $DB->get_field('role', 'MAX(sortorder) + 1', array());
示例4: 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
if (!data_submitted()) {
///Basic prevention
print_error('wrongcall', 'error');
}
/// Get parameters
$dirpath = required_param('dir', PARAM_PATH);
$dirpath = $CFG->dirroot . $dirpath;
$tableparam = strtolower(required_param('table', PARAM_PATH));
$indexparam = strtolower(required_param('index', PARAM_PATH));
$name = trim(strtolower(optional_param('name', $indexparam, PARAM_PATH)));
$comment = required_param('comment', PARAM_CLEAN);
$comment = trim($comment);
$unique = required_param('unique', PARAM_INT);
$fields = required_param('fields', PARAM_CLEAN);
$fields = str_replace(' ', '', trim(strtolower($fields)));
$editeddir =& $XMLDB->editeddirs[$dirpath];
$structure =& $editeddir->xml_file->getStructure();
$table =& $structure->getTable($tableparam);
$index =& $table->getIndex($indexparam);
$oldhash = $index->getHash();
$errors = array();
/// To store all the errors found
/// Perform some checks
/// Check empty name
if (empty($name)) {
$errors[] = $this->str['indexnameempty'];
}
/// Check incorrect name
if ($name == 'changeme') {
$errors[] = $this->str['incorrectindexname'];
}
/// Check duplicate name
if ($indexparam != $name && $table->getIndex($name)) {
$errors[] = $this->str['duplicateindexname'];
}
$fieldsarr = explode(',', $fields);
/// Check the fields isn't empty
if (empty($fieldsarr[0])) {
$errors[] = $this->str['nofieldsspecified'];
} else {
/// Check that there aren't duplicate column names
$uniquearr = array_unique($fieldsarr);
if (count($fieldsarr) != count($uniquearr)) {
$errors[] = $this->str['duplicatefieldsused'];
}
/// Check that all the fields in belong to the table
foreach ($fieldsarr as $field) {
if (!$table->getField($field)) {
$errors[] = $this->str['fieldsnotintable'];
break;
}
}
/// Check that there isn't any key using exactly the same fields
$tablekeys = $table->getKeys();
if ($tablekeys) {
foreach ($tablekeys as $tablekey) {
$keyfieldsarr = $tablekey->getFields();
/// Compare both arrays, looking for diferences
$diferences = array_merge(array_diff($fieldsarr, $keyfieldsarr), array_diff($keyfieldsarr, $fieldsarr));
if (empty($diferences)) {
$errors[] = $this->str['fieldsusedinkey'];
break;
}
}
}
/// Check that there isn't any index using exactlt the same fields
$tableindexes = $table->getIndexes();
if ($tableindexes) {
foreach ($tableindexes as $tableindex) {
/// Skip checking against itself
if ($indexparam == $tableindex->getName()) {
continue;
}
$indexfieldsarr = $tableindex->getFields();
/// Compare both arrays, looking for diferences
$diferences = array_merge(array_diff($fieldsarr, $indexfieldsarr), array_diff($indexfieldsarr, $fieldsarr));
if (empty($diferences)) {
$errors[] = $this->str['fieldsusedinindex'];
break;
}
}
}
}
if (!empty($errors)) {
$tempindex = new xmldb_index($name);
//.........这里部分代码省略.........
示例5: arr2xmldb_table
//.........这里部分代码省略.........
$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);
$result = false;
}
/// Perform some general checks over keys
if ($result && $this->keys) {
/// Check keys names are ok (lowercase, a-z _-)
if (!$this->checkNameValues($this->keys)) {
$this->errormsg = 'Some KEYS name values are incorrect';
$this->debug($this->errormsg);
$result = false;
}
/// Check previous & next are ok (duplicates and existing keys)
$this->fixPrevNext($this->keys);
if ($result && !$this->checkPreviousNextValues($this->keys)) {
$this->errormsg = 'Some KEYS previous/next values are incorrect';
$this->debug($this->errormsg);
$result = false;
}
/// Order keys
if ($result && !$this->orderKeys($this->keys)) {
$this->errormsg = 'Error ordering the keys';
$this->debug($this->errormsg);
$result = false;
}
/// TODO: Only one PK
/// TODO: Not keys with repeated fields
/// TODO: Check fields and reffieds exist in table
}
/// Iterate over indexes
if (isset($xmlarr['#']['INDEXES']['0']['#']['INDEX'])) {
foreach ($xmlarr['#']['INDEXES']['0']['#']['INDEX'] as $xmlindex) {
if (!$result) {
//Skip on error
continue;
}
$name = trim($xmlindex['@']['NAME']);
$index = new xmldb_index($name);
$index->arr2xmldb_index($xmlindex);
$this->indexes[] = $index;
if (!$index->isLoaded()) {
$this->errormsg = 'Problem loading index ' . $name;
$this->debug($this->errormsg);
$result = false;
}
}
}
/// Perform some general checks over indexes
if ($result && $this->indexes) {
/// Check field names are ok (lowercase, a-z _-)
if (!$this->checkNameValues($this->indexes)) {
$this->errormsg = 'Some INDEXES name values are incorrect';
$this->debug($this->errormsg);
$result = false;
}
/// Check previous & next are ok (duplicates and existing INDEXES)
$this->fixPrevNext($this->indexes);
if ($result && !$this->checkPreviousNextValues($this->indexes)) {
$this->errormsg = 'Some INDEXES previous/next values are incorrect';
$this->debug($this->errormsg);
$result = false;
}
/// Order indexes
if ($result && !$this->orderIndexes($this->indexes)) {
$this->errormsg = 'Error ordering the indexes';
$this->debug($this->errormsg);
$result = false;
}
/// TODO: Not indexes with repeated fields
/// TODO: Check fields exist in table
}
/// Set some attributes
if ($result) {
$this->loaded = true;
}
$this->calculateHash();
return $result;
}
示例6: invoke
//.........这里部分代码省略.........
$test = new stdClass();
$field = new xmldb_field('secondname');
$field->set_attributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, 'Moodle2');
$test->sql = $gen->getModifyDefaultSQL($table, $field);
try {
$dbman->change_field_default($table, $field, false, false);
$test->status = true;
} catch (moodle_exception $e) {
$test->status = false;
$test->error = $DB->get_last_error() . "\n" . $e;
}
$tests['add field default of NOT NULL field'] = $test;
}
/// 26th test. Dropping the default of one NOT NULL field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass();
$field = new xmldb_field('secondname');
$field->set_attributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null);
$test->sql = $gen->getModifyDefaultSQL($table, $field);
try {
$dbman->change_field_default($table, $field, false, false);
$test->status = true;
} catch (moodle_exception $e) {
$test->status = false;
$test->error = $DB->get_last_error() . "\n" . $e;
}
$tests['drop field default of NOT NULL field'] = $test;
}
/// 27th test. Adding one unique index to the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass();
$index = new xmldb_index('secondname');
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('name', 'secondname', 'grade'));
$test->sql = $gen->getAddIndexSQL($table, $index);
try {
$dbman->add_index($table, $index, false, false);
$test->status = true;
} catch (moodle_exception $e) {
$test->status = false;
$test->error = $DB->get_last_error() . "\n" . $e;
}
$tests['add unique index'] = $test;
}
/// 28th test. Adding one not unique index to the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass();
$index = new xmldb_index('secondname');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$test->sql = $gen->getAddIndexSQL($table, $index);
try {
$dbman->add_index($table, $index, false, false);
$test->status = true;
} catch (moodle_exception $e) {
$test->status = false;
$test->error = $DB->get_last_error() . "\n" . $e;
}
$tests['add not unique index'] = $test;
}
/// 29th test. Re-add the same index than previous test. Check find_index_name() works.
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass();
$index = new xmldb_index('secondname');
示例7: xmldb_facetoface_upgrade
//.........这里部分代码省略.........
if ($dbman->field_exists($table, $field)) {
$result = $result && $dbman->drop_field($table, $field, false, true);
}
}
// 2.0 upgrade line.
if ($oldversion < 2011120701) {
// Update existing select fields to use new seperator.
$badrows = $DB->get_records_sql("\n SELECT\n *\n FROM\n {facetoface_session_field}\n WHERE\n possiblevalues LIKE '%;%'\n AND possiblevalues NOT LIKE '%" . CUSTOMFIELD_DELIMITER . "%'\n AND type IN (" . CUSTOMFIELD_TYPE_SELECT . "," . CUSTOMFIELD_TYPE_MULTISELECT . ")\n ");
if ($badrows) {
$transaction = $DB->start_delegated_transaction();
foreach ($badrows as $bad) {
$fixedrow = new stdClass();
$fixedrow->id = $bad->id;
$fixedrow->possiblevalues = str_replace(';', CUSTOMFIELD_DELIMITER, $bad->possiblevalues);
$DB->update_record('facetoface_session_field', $fixedrow);
}
$transaction->allow_commit();
}
$baddatarows = $DB->get_records_sql("\n SELECT\n sd.id, sd.data\n FROM\n {facetoface_session_field} sf\n JOIN\n {facetoface_session_data} sd\n ON\n sd.fieldid=sf.id\n WHERE\n sd.data LIKE '%;%'\n AND sd.data NOT LIKE '%" . CUSTOMFIELD_DELIMITER . "%'\n AND sf.type = " . CUSTOMFIELD_TYPE_MULTISELECT);
if ($baddatarows) {
$transaction = $DB->start_delegated_transaction();
foreach ($baddatarows as $bad) {
$fixedrow = new stdClass();
$fixedrow->id = $bad->id;
$fixedrow->data = str_replace(';', CUSTOMFIELD_DELIMITER, $bad->data);
$DB->update_record('facetoface_session_data', $fixedrow);
}
$transaction->allow_commit();
}
upgrade_mod_savepoint(true, 2011120701, 'facetoface');
}
if ($oldversion < 2011120702) {
$table = new xmldb_table('facetoface_session_field');
$index = new xmldb_index('ind_session_field_unique');
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('shortname'));
if ($dbman->table_exists($table)) {
// Do we need to check for duplicates?
if (!$dbman->index_exists($table, $index)) {
// Check for duplicate records and make them unique.
$replacements = array();
$transaction = $DB->start_delegated_transaction();
$sql = 'SELECT
l.id,
l.shortname
FROM
{facetoface_session_field} l,
( SELECT
MIN(id) AS id,
shortname
FROM
{facetoface_session_field}
GROUP BY
shortname
HAVING COUNT(*)>1
) a
WHERE
l.id<>a.id
AND l.shortname = a.shortname
';
$rs = $DB->get_recordset_sql($sql, null);
if ($rs !== false) {
foreach ($rs as $item) {
$data = (object) $item;
// Randomize the value.
$data->shortname = $DB->escape($data->shortname . '_' . $data->id);
$DB->update_record('facetoface_session_field', $data);
示例8: xmldb_main_upgrade
/**
*
* @global stdClass $CFG
* @global stdClass $USER
* @global moodle_database $DB
* @global core_renderer $OUTPUT
* @param int $oldversion
* @return bool always true
*/
function xmldb_main_upgrade($oldversion)
{
global $CFG, $USER, $DB, $OUTPUT;
require_once $CFG->libdir . '/db/upgradelib.php';
// Core Upgrade-related functions
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
////////////////////////////////////////
///upgrade supported only from 1.9.x ///
////////////////////////////////////////
if ($oldversion < 2008030600) {
//NOTE: this table was added much later later in dev cycle, but we need it here, upgrades from pre PR1 not supported
/// Define table upgrade_log to be created
$table = new xmldb_table('upgrade_log');
/// Adding fields to table upgrade_log
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('targetversion', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table upgrade_log
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
/// Adding indexes to table upgrade_log
$table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
$table->add_index('type-timemodified', XMLDB_INDEX_NOTUNIQUE, array('type', 'timemodified'));
/// Create table for upgrade_log
$dbman->create_table($table);
/// Main savepoint reached
upgrade_main_savepoint(true, 2008030600);
}
if ($oldversion < 2008030601) {
//NOTE: this table was added much later later in dev cycle, but we need it here, upgrades from pre PR1 not supported
/// Define table log_queries to be created
$table = new xmldb_table('log_queries');
/// Adding fields to table log_queries
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('qtype', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('sqltext', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null);
$table->add_field('sqlparams', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
$table->add_field('error', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('info', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('exectime', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null);
$table->add_field('timelogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table log_queries
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Conditionally launch create table for log_queries
$dbman->create_table($table);
/// Main savepoint reached
upgrade_main_savepoint(true, 2008030601);
}
if ($oldversion < 2008030602) {
@unlink($CFG->dataroot . '/cache/languages');
if (file_exists("{$CFG->dataroot}/lang")) {
// rename old lang directory so that the new and old langs do not mix
if (rename("{$CFG->dataroot}/lang", "{$CFG->dataroot}/oldlang")) {
$oldlang = "{$CFG->dataroot}/oldlang";
} else {
$oldlang = "{$CFG->dataroot}/lang";
}
} else {
$oldlang = '';
}
// TODO: fetch previously installed languages ("*_utf8") found in $oldlang from moodle.org
upgrade_set_timeout(60 * 20);
// this may take a while
// TODO: add some info file to $oldlang describing what to do with "$oldlang/*_utf8_local" dirs
// Main savepoint reached
upgrade_main_savepoint(true, 2008030602);
}
if ($oldversion < 2008030700) {
upgrade_set_timeout(60 * 20);
// this may take a while
/// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
$table = new xmldb_table('grade_letters');
$index = new xmldb_index('contextid-lowerboundary', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
/// Launch drop index contextid-lowerboundary
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
/// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters
$table = new xmldb_table('grade_letters');
$index = new xmldb_index('contextid-lowerboundary-letter', XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
/// Launch add index contextid-lowerboundary-letter
$dbman->add_index($table, $index);
//.........这里部分代码省略.........
示例9: xmldb_questionnaire_upgrade
//.........这里部分代码省略.........
$dbman->drop_field($table, $field);
// Questionnaire savepoint reached.
upgrade_mod_savepoint(true, 2008031905, 'questionnaire');
}
if ($oldversion < 2008031906) {
$table = new xmldb_table('questionnaire_response_rank');
$field = new xmldb_field('rank');
$field->set_attributes(XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null, null, '0', 'choice_id');
$field->setUnsigned(false);
$dbman->change_field_unsigned($table, $field);
// Questionnaire savepoint reached.
upgrade_mod_savepoint(true, 2008031906, 'questionnaire');
}
if ($oldversion < 2008060401) {
$table = new xmldb_table('questionnaire_question');
$field = new xmldb_field('name');
$field->set_attributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'survey_id');
$field->setNotnull(false);
$dbman->change_field_notnull($table, $field);
// Questionnaire savepoint reached.
upgrade_mod_savepoint(true, 2008060401, 'questionnaire');
}
if ($oldversion < 2008070702) {
$table = new xmldb_table('questionnaire_question_type');
$field = new xmldb_field('response_table');
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null, 'has_choices');
$field->setNotnull(false);
$dbman->change_field_notnull($table, $field);
// Questionnaire savepoint reached.
upgrade_mod_savepoint(true, 2008070702, 'questionnaire');
}
if ($oldversion < 2008070703) {
$table = new xmldb_table('questionnaire_resp_multiple');
$index = new xmldb_index('response_question');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('response_id', 'question_id', 'choice_id'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Questionnaire savepoint reached.
upgrade_mod_savepoint(true, 2008070703, 'questionnaire');
}
if ($oldversion < 2008070704) {
// CONTRIB-1542.
$table = new xmldb_table('questionnaire_survey');
$field = new xmldb_field('email');
$field->set_attributes(XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, null, null, 'title');
$field->setLength('255');
$dbman->change_field_precision($table, $field);
// Questionnaire savepoint reached.
upgrade_mod_savepoint(true, 2008070704, 'questionnaire');
}
if ($oldversion < 2008070705) {
// Rename summary field to 'intro' to adhere to new Moodle standard.
$table = new xmldb_table('questionnaire');
$field = new xmldb_field('summary');
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
$dbman->rename_field($table, $field, 'intro');
// Add 'introformat' to adhere to new Moodle standard.
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
$dbman->add_field($table, $field);
// Set all existing records to HTML format.
$DB->set_field('questionnaire', 'introformat', 1);
// Questionnaire savepoint reached.
upgrade_mod_savepoint(true, 2008070705, 'questionnaire');
}
if ($oldversion < 2008070706) {
示例10: xmldb_teambuilder_upgrade
function xmldb_teambuilder_upgrade($oldversion = 0)
{
global $CFG, $DB;
$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.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of "/lib/ddllib.php" function calls
/// }
/// Lines below (this included) MUST BE DELETED once you get the first version
/// of your module ready to be installed. They are here only
/// for demonstrative purposes and to show how the teambuilder
/// iself has been upgraded.
/// For each upgrade block, the file teambuilder/version.php
/// needs to be updated . Such change allows Moodle to know
/// that this file has to be processed.
/// To know more about how to write correct DB upgrade scripts it's
/// highly recommended to read information available at:
/// http://docs.moodle.org/en/Development:XMLDB_Documentation
/// and to play with the XMLDB Editor (in the admin menu) and its
/// PHP generation posibilities.
/// First example, some fields were added to the module on 20070400
if ($oldversion < 2007040100) {
/// Define field course to be added to teambuilder
$table = new xmldb_table('teambuilder');
$field = new xmldb_field('course');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id');
/// Launch add field course
$dbman->add_field($table, $field);
/// Define field intro to be added to teambuilder
$table = new xmldb_table('teambuilder');
$field = new xmldb_field('intro');
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'name');
/// Launch add field intro
$dbman->add_field($table, $field);
/// Define field introformat to be added to teambuilder
$table = new xmldb_table('teambuilder');
$field = new xmldb_field('introformat');
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
/// Launch add field introformat
$dbman->add_field($table, $field);
upgrade_mod_savepoint(true, 2007040100, 'teambuilder');
}
/// Second example, some hours later, the same day 20070401
/// two more fields and one index were added (note the increment
/// "01" in the last two digits of the version
if ($oldversion < 2007040101) {
/// Define field timecreated to be added to teambuilder
$table = new xmldb_table('teambuilder');
$field = new xmldb_field('timecreated');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'introformat');
/// Launch add field timecreated
$dbman->add_field($table, $field);
/// Define field timemodified to be added to teambuilder
$table = new xmldb_table('teambuilder');
$field = new xmldb_field('timemodified');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timecreated');
/// Launch add field timemodified
$dbman->add_field($table, $field);
/// Define index course (not unique) to be added to teambuilder
$table = new xmldb_table('teambuilder');
$index = new xmldb_index('course');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
/// Launch add index course
$dbman->add_index($table, $index);
upgrade_mod_savepoint(true, 2007040101, 'teambuilder');
}
/// Third example, the next day, 20070402 (with the trailing 00), some inserts were performed, related with the module
if ($oldversion < 2007040200) {
/// Add some actions to get them properly displayed in the logs
$rec = new stdClass();
$rec->module = 'teambuilder';
$rec->action = 'add';
$rec->mtable = 'teambuilder';
$rec->filed = 'name';
/// Insert the add action in log_display
$DB->insert_record('log_display', $rec);
/// Now the update action
$rec->action = 'update';
$DB->insert_record('log_display', $rec);
/// Now the view action
$rec->action = 'view';
$DB->insert_record('log_display', $rec);
upgrade_mod_savepoint(true, 2007040200, 'teambuilder');
}
if ($oldversion < 2011051702) {
$table = new xmldb_table('teambuilder');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
// Launch add field introformat
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2011051702, 'teambuilder');
}
/// And that's all. Please, examine and understand the 3 example blocks above. Also
/// it's interesting to look how other modules are using this script. Remember that
/// the basic idea is to have "blocks" of code (each one being executed only once,
/// when the module version (version.php) is updated.
//.........这里部分代码省略.........
示例11: xmldb_main_upgrade
function xmldb_main_upgrade($oldversion)
{
global $CFG, $THEME, $USER, $DB, $OUTPUT;
require_once $CFG->libdir . '/db/upgradelib.php';
// Core Upgrade-related functions
$result = true;
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
////////////////////////////////////////
///upgrade supported only from 1.9.x ///
////////////////////////////////////////
if ($result && $oldversion < 2008030600) {
//NOTE: this table was added much later, that is why this step is repeated later in this file
/// Define table upgrade_log to be created
$table = new xmldb_table('upgrade_log');
/// Adding fields to table upgrade_log
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table upgrade_log
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
/// Adding indexes to table upgrade_log
$table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
$table->add_index('type-timemodified', XMLDB_INDEX_NOTUNIQUE, array('type', 'timemodified'));
/// Create table for upgrade_log
$dbman->create_table($table);
/// Main savepoint reached
upgrade_main_savepoint($result, 2008030600);
}
if ($result && $oldversion < 2008030700) {
upgrade_set_timeout(60 * 20);
// this may take a while
/// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
$table = new xmldb_table('grade_letters');
$index = new xmldb_index('contextid-lowerboundary', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
/// Launch drop index contextid-lowerboundary
$dbman->drop_index($table, $index);
/// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters
$table = new xmldb_table('grade_letters');
$index = new xmldb_index('contextid-lowerboundary-letter', XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
/// Launch add index contextid-lowerboundary-letter
$dbman->add_index($table, $index);
/// Main savepoint reached
upgrade_main_savepoint($result, 2008030700);
}
if ($result && $oldversion < 2008050100) {
// Update courses that used weekscss to weeks
$result = $DB->set_field('course', 'format', 'weeks', array('format' => 'weekscss'));
upgrade_main_savepoint($result, 2008050100);
}
if ($result && $oldversion < 2008050200) {
// remove unused config options
unset_config('statsrolesupgraded');
upgrade_main_savepoint($result, 2008050200);
}
if ($result && $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';
$result = $result && question_fix_random_question_parents();
upgrade_main_savepoint($result, 2008050700);
}
if ($result && $oldversion < 2008051200) {
// if guest role used as default user role unset it and force admin to choose new setting
if (!empty($CFG->defaultuserroleid)) {
if ($role = $DB->get_record('role', array('id' => $CFG->defaultuserroleid))) {
if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
if (isset($guestroles[$role->id])) {
set_config('defaultuserroleid', null);
echo $OUTPUT->notification('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess');
}
}
} else {
set_config('defaultuserroleid', null);
}
}
/// Main savepoint reached
upgrade_main_savepoint($result, 2008051200);
}
if ($result && $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
//.........这里部分代码省略.........
示例12: xmldb_block_lockdownbrowser_upgrade
function xmldb_block_lockdownbrowser_upgrade($oldversion = 0)
{
global $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2012082000) {
// table names limited to 28 characters in Moodle 2.3+
$table = new xmldb_table("block_lockdownbrowser_settings");
if ($dbman->table_exists($table)) {
$dbman->rename_table($table, "block_lockdownbrowser_sett");
}
$table = new xmldb_table("block_lockdownbrowser_tokens");
if ($dbman->table_exists($table)) {
$dbman->rename_table($table, "block_lockdownbrowser_toke");
}
$table = new xmldb_table("block_lockdownbrowser_sessions");
if ($dbman->table_exists($table)) {
$dbman->rename_table($table, "block_lockdownbrowser_sess");
}
upgrade_block_savepoint(true, 2012082000, "lockdownbrowser");
}
if ($oldversion < 2013011800) {
$table = new xmldb_table("block_lockdownbrowser");
$index = new xmldb_index("course_ix");
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array("course"));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$table = new xmldb_table("block_lockdownbrowser_sett");
$field = new xmldb_field("course", XMLDB_TYPE_INTEGER, "10", XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, "id");
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field("monitor", XMLDB_TYPE_TEXT, "small", null, null, null, null, "password");
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$index = new xmldb_index("course_ix");
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array("course"));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$index = new xmldb_index("quiz_ix");
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array("quizid"));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
upgrade_block_savepoint(true, 2013011800, "lockdownbrowser");
}
if ($oldversion < 2013012800) {
// no db stuff to upgrade
}
if ($oldversion < 2013020500) {
// no db stuff to upgrade
}
if ($oldversion < 2013021500) {
// no db stuff to upgrade
}
if ($oldversion < 2013022000) {
// no db stuff to upgrade
}
if ($oldversion < 2013022100) {
// no db stuff to upgrade
}
if ($oldversion < 2013022800) {
// no db stuff to upgrade
}
if ($oldversion < 2013031900) {
// no db stuff to upgrade
}
if ($oldversion < 2013032600) {
// no db stuff to upgrade
}
return true;
}
示例13: xmldb_facetoface_upgrade
//.........这里部分代码省略.........
"
SELECT
sd.id, sd.data
FROM
{facetoface_session_field} sf
JOIN
{facetoface_session_data} sd
ON
sd.fieldid=sf.id
WHERE
sd.data LIKE '%;%'
AND sd.data NOT LIKE '%". CUSTOMFIELD_DELIMITER ."%'
AND sf.type = ".CUSTOMFIELD_TYPE_MULTISELECT
);
if ($bad_data_rows) {
$transaction = $DB->start_delegated_transaction();
foreach ($bad_data_rows as $bad) {
$fixedrow = new stdClass();
$fixedrow->id = $bad->id;
$fixedrow->data = str_replace(';', CUSTOMFIELD_DELIMITER, $bad->data);
$DB->update_record('facetoface_session_data', $fixedrow);
}
$transaction->allow_commit();
}
upgrade_mod_savepoint(true, 2011120701, 'facetoface');
}
if ($oldversion < 2011120702) {
$table = new xmldb_table('facetoface_session_field');
$index = new xmldb_index('ind_session_field_unique');
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('shortname'));
if ($dbman->table_exists($table)) {
//do we need to check for duplicates?
if (!$dbman->index_exists($table, $index)) {
//check for duplicate records and make them unique
$replacements = array();
$transaction = $DB->start_delegated_transaction();
$sql = 'SELECT
l.id,
l.shortname
FROM
{facetoface_session_field} l,
( SELECT
MIN(id) AS id,
shortname
FROM
{facetoface_session_field}
GROUP BY
shortname
HAVING COUNT(*)>1
) a
WHERE
l.id<>a.id
AND l.shortname = a.shortname
';
$rs = $DB->get_recordset_sql($sql, null);
示例14: testDropIndex
public function testDropIndex()
{
$dbman = $this->tdb->get_manager();
$table = $this->create_deftable('test_table1');
$index = new xmldb_index('secondname');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$dbman->add_index($table, $index);
$dbman->drop_index($table, $index);
$this->assertFalse($dbman->find_index_name($table, $index));
}
示例15: xmldb_referentiel_upgrade
//.........这里部分代码省略.........
/// Adding fields to table chat_messages_current
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('promotion', XMLDB_TYPE_CHAR, '4', null, null, null, null);
$table->add_field('num_groupe', XMLDB_TYPE_CHAR, '20', null, null, null, null);
$table->add_field('date_cloture', XMLDB_TYPE_CHAR, '20', null, null, null, null);
$table->add_field('formation', XMLDB_TYPE_CHAR, '40', null, null, null, null);
$table->add_field('pedagogie', XMLDB_TYPE_CHAR, '40', null, null, null, null);
$table->add_field('composante', XMLDB_TYPE_CHAR, '40', null, null, null, null);
$table->add_field('commentaire', XMLDB_TYPE_CHAR, '40', null, null, null, null);
/// Adding keys to table
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// create table
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Define table referentiel_a_user_pedagogie to be created
$table = new xmldb_table('referentiel_a_user_pedagogie');
/// Adding fields
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('refrefid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('refpedago', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
/// Adding keys to table
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// create table
if (!$dbman->table_exists($table)) {
$dbman->create_table($table, true, true);
}
upgrade_mod_savepoint(true, 2011031100, 'referentiel');
}
if ($oldversion < 2011042204) {
/*
/// Adding index to table referentiel_notification_queue
$index = new xmldb_index('user');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
*/
// Supprimer une source d'erreur lors de la creation d'un certificat
/// Define index uniqueuser (unique) to be dropped from referentiel_certificat
$table = new xmldb_table('referentiel_certificat');
$index = new xmldb_index('uniqueuser');
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('userid'));
/// Launch drop index uniqueuser
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
// recreer index non unique
/// Define index indexuser (not unique) to be added to referentiel_certificat
$table = new xmldb_table('referentiel_certificat');
$index = new xmldb_index('indexuser');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
/// Launch drop index uniqueuser
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
upgrade_mod_savepoint(true, 2011042204, 'referentiel');
}
if ($oldversion < 2011042205) {
// VERSION 5.6.01
/// Define index userpedagoref (unique) to be added to referentiel_a_user_pedagogie
$table = new xmldb_table('referentiel_a_user_pedagogie');
$index = new xmldb_index('userpedagoref');
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('userid', 'refrefid', 'refpedago'));
/// Launch drop index uniqueuser