本文整理汇总了PHP中xmldb_field::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_field::setAttributes方法的具体用法?PHP xmldb_field::setAttributes怎么用?PHP xmldb_field::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmldb_field
的用法示例。
在下文中一共展示了xmldb_field::setAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_turnitintool_upgrade
/**
* @package turnitintool
* @copyright 2012 Turnitin
*/
function xmldb_turnitintool_upgrade($oldversion)
{
global $CFG, $THEME, $DB, $OUTPUT;
$result = true;
// Do necessary DB upgrades here
//function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null)
// Newer DB Man ($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null)
if ($result && $oldversion < 2009071501) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
$table = new xmldb_table('turnitintool_submissions');
$field = new xmldb_field('submission_gmimaged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'submission_grade');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
} else {
$table = new XMLDBTable('turnitintool_submissions');
$field = new XMLDBField('submission_gmimaged');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'submission_grade');
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2009091401) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
$table = new xmldb_table('turnitintool');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
} else {
$table = new XMLDBTable('turnitintool');
$field = new XMLDBField('introformat');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro');
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2009092901) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
$table1 = new xmldb_table('turnitintool');
$field1 = new xmldb_field('resubmit', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'defaultdtpost');
if ($dbman->field_exists($table1, $field1)) {
$dbman->rename_field($table1, $field1, 'anon');
}
$table2 = new xmldb_table('turnitintool_submissions');
$field2 = new xmldb_field('submission_unanon', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, NULL, null, null, null, '0', 'submission_nmlastname');
$field3 = new xmldb_field('submission_unanonreason', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'submission_unanon');
$field4 = new xmldb_field('submission_nmuserid', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null);
if (!$dbman->field_exists($table2, $field2)) {
$dbman->add_field($table2, $field2);
}
if (!$dbman->field_exists($table2, $field3)) {
$dbman->add_field($table2, $field3);
}
$dbman->change_field_type($table2, $field4);
} else {
$table1 = new XMLDBTable('turnitintool');
$field1 = new XMLDBField('resubmit');
$field1->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'defaultdtpost');
$result = $result && rename_field($table1, $field1, 'anon');
$table2 = new XMLDBTable('turnitintool_submissions');
$field2 = new XMLDBField('submission_unanon');
$field3 = new XMLDBField('submission_unanonreason');
$field4 = new XMLDBField('submission_nmuserid');
$field2->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'submission_nmlastname');
$result = $result && add_field($table2, $field2);
$field3->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'submission_unanon');
$result = $result && add_field($table2, $field3);
$field4->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
$result = $result && change_field_type($table2, $field4);
}
}
if ($result && $oldversion < 2009120501) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
// Launch add index userid
$table = new xmldb_table('turnitintool_submissions');
$index = new xmldb_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Launch add index turnitintoolid
$table = new xmldb_table('turnitintool_submissions');
$index = new xmldb_index('turnitintoolid', XMLDB_INDEX_NOTUNIQUE, array('turnitintoolid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
} else {
$table = new XMLDBTable('turnitintool_submissions');
// Launch add index userid
$index = new XMLDBIndex('userid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
if (index_exists($table, $index)) {
$result = $result && add_index($table, $index);
}
//.........这里部分代码省略.........