本文整理汇总了PHP中XMLDBField::setLength方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBField::setLength方法的具体用法?PHP XMLDBField::setLength怎么用?PHP XMLDBField::setLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDBField
的用法示例。
在下文中一共展示了XMLDBField::setLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_core_upgrade
//.........这里部分代码省略.........
foreach ($configdata as $key => $value) {
$configdata[$key] = preg_replace('/\\/emotions\\/img/', '/emotions/img', $value);
}
$bi->set('configdata', $configdata);
$bi->commit();
$count++;
if ($count % $limit == 0 || $count == $total) {
log_debug("{$count}/{$total}");
set_time_limit(30);
}
}
}
}
if ($oldversion < 2015041400) {
log_debug('Force install of annotation and webservices plugins');
if ($data = check_upgrades('artefact.annotation')) {
upgrade_plugin($data);
}
if ($data = check_upgrades('auth.webservice')) {
upgrade_plugin($data);
}
}
if ($oldversion < 2015042800) {
log_debug('Clear Dwoo cache of unescaped institution names');
require_once 'dwoo/dwoo/dwooAutoload.php';
@unlink(get_config('dataroot') . 'dwoo/compile/default' . get_config('docroot') . 'theme/raw/' . 'templates/view/accesslistrow.tpl.d' . Dwoo_Core::RELEASE_TAG . '.php');
@unlink(get_config('dataroot') . 'dwoo/compile/default' . get_config('docroot') . 'theme/raw/' . 'templates/admin/users/accesslistitem.tpl.d' . Dwoo_Core::RELEASE_TAG . '.php');
}
if ($oldversion < 2015071500) {
log_debug('Expanding the size of the import_entry_requests.entrycontent column');
$table = new XMLDBTable('import_entry_requests');
$field = new XMLDBField('entrycontent');
$field->setType(XMLDB_TYPE_TEXT);
$field->setLength('big');
change_field_precision($table, $field);
}
if ($oldversion < 2015072000) {
// If we are upgrading from a site built before 2014092300 straight to 15.10
// then the plugin won't exist as an artefact.
if (table_exists(new XMLDBTable('artefact_multirecipient_userrelation'))) {
log_debug('Change installation of artefact plugin multirecipentNotification to plugin module.');
// first, drop the old triggers
db_drop_trigger('update_unread_insert2', 'artefact_multirecipient_userrelation');
db_drop_trigger('update_unread_update2', 'artefact_multirecipient_userrelation');
db_drop_trigger('update_unread_delete2', 'artefact_multirecipient_userrelation');
// rename tables artefact_multirecipientnotifiaction_notification and
// Table: artefact_multirecipient_userrelation to module-prefix
execute_sql("ALTER TABLE {artefact_multirecipient_notification} RENAME TO {module_multirecipient_notification}");
execute_sql("ALTER TABLE {artefact_multirecipient_userrelation} RENAME TO {module_multirecipient_userrelation}");
if (is_postgres()) {
// Rename seq artefact_multirecipientnotifiaction_notification_id_seq and
// artefact_multirecipient_userrelation_id_seq
execute_sql("ALTER SEQUENCE {artefact_multirecipient_notification_id_seq} RENAME TO {module_multirecipient_notification_id_seq}");
execute_sql("ALTER SEQUENCE {artefact_multirecipient_userrelation_id_seq} RENAME TO {module_multirecipient_userrelation_id_seq}");
}
//move event_subscrition entries for artefact plugin
//multirecipientnotification to table module_event_subscription
$subscriptions = get_records_array('artefact_event_subscription', 'plugin', 'multirecipientnotification');
delete_records('artefact_event_subscription', 'plugin', 'multirecipientnotification');
delete_records('artefact_installed_type', 'plugin', 'multirecipientnotification');
$installrecord = get_record('artefact_installed', 'name', 'multirecipientnotification');
if (is_object($installrecord)) {
insert_record('module_installed', $installrecord);
delete_records('artefact_installed', 'name', 'multirecipientnotification');
}
if (is_array($subscriptions)) {
示例2: xmldb_main_upgrade
//.........这里部分代码省略.........
$table->comment = 'A service is a group of functions';
// fields
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$f = $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('description', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('apiversion', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('offer', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
// Create the table
$result = $result && create_table($table);
$table = new XMLDBTable('mnet_service2rpc');
$table->comment = 'Group functions or methods under a service';
// fields
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$f = $table->addFieldInfo('serviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('rpcid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('unique', XMLDB_INDEX_UNIQUE, array('rpcid', 'serviceid'));
// Create the table
$result = $result && create_table($table);
//
// Prime MNET configuration entries -- will be needed later by auth/mnet
//
include_once $CFG->dirroot . '/mnet/lib.php';
$env = new mnet_environment();
$env->init();
unset($env);
// add mnethostid to user-
$table = new XMLDBTable('user');
$field = new XMLDBField('mnethostid');
$field->setType(XMLDB_TYPE_INTEGER);
$field->setLength(10);
$field->setNotNull(true);
$field->setSequence(null);
$field->setEnum(null);
$field->setDefault('0');
$field->setPrevious("deleted");
$field->setNext("username");
$result = $result && add_field($table, $field);
// The default mnethostid is zero... we need to update this for all
// users of the local IdP service.
set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'mnethostid', '0');
$index = new XMLDBIndex('username');
$index->setUnique(true);
$index->setFields(array('username'));
drop_index($table, $index);
$index->setFields(array('mnethostid', 'username'));
if (!add_index($table, $index)) {
notify(get_string('duplicate_usernames', 'mnet', 'http://docs.moodle.org/en/DuplicateUsernames'));
}
unset($table, $field, $index);
/**
** auth/mnet tables
**/
$table = new XMLDBTable('mnet_session');
$table->comment = 'Store session data from users migrating to other sites';
// fields
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$f = $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('token', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('mnethostid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('useragent', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('confirm_timeout', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
示例3: invoke
//.........这里部分代码省略.........
foreach ($enumarr as $key => $enumelement) {
/// Clear some spaces
$enumarr[$key] = trim($enumelement);
$enumelement = trim($enumelement);
/// Calculate needed length
$le = strlen(str_replace("'", '', $enumelement));
if ($le > $maxlength) {
$maxlength = $le;
}
/// Skip if under error
if ($enumerr) {
continue;
}
/// Look for quoted strings
if (substr($enumelement, 0, 1) != "'" || substr($enumelement, -1, 1) != "'") {
$enumerr = true;
}
}
} else {
$enumerr = true;
}
if ($enumerr) {
$errors[] = $this->str['enumvaluesincorrect'];
} else {
$enumvalues = $enumarr;
}
if ($length < $maxlength) {
$errors[] = $this->str['wronglengthforenum'];
}
}
if (!empty($errors)) {
$tempfield = new XMLDBField($name);
$tempfield->setType($type);
$tempfield->setLength($length);
$tempfield->setDecimals($decimals);
$tempfield->setUnsigned($unsigned);
$tempfield->setNotNull($notnull);
$tempfield->setSequence($sequence);
$tempfield->setEnum($enum);
$tempfield->setEnumValues($enumvalues);
$tempfield->setDefault($default);
/// Prepare the output
$site = get_site();
$navlinks = array();
$navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc');
$navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("{$site->shortname}: XMLDB", "{$site->fullname}", $navigation);
notice('<p>' . implode(', ', $errors) . '</p>
<p>' . $tempfield->readableInfo(), 'index.php?action=edit_field&field=' . $field->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
die;
/// re-die :-P
}
/// Continue if we aren't under errors
if (empty($errors)) {
/// If there is one name change, do it, changing the prev and next
/// atributes of the adjacent fields
if ($fieldparam != $name) {
$field->setName($name);
if ($field->getPrevious()) {
$prev =& $table->getField($field->getPrevious());
$prev->setNext($name);
$prev->setChanged(true);
}
if ($field->getNext()) {
$next =& $table->getField($field->getNext());
示例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
/// Get the dir containing the file
$dirpath = required_param('dir', PARAM_PATH);
$dirpath = $CFG->dirroot . stripslashes_safe($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();
}
/// ADD YOUR CODE HERE
/// 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 XMLDBField('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 XMLDBKey('primary');
$key->setType(XMLDB_KEY_PRIMARY);
$key->setFields(array('id'));
$key->setLoaded(true);
$key->setChanged(true);
$table = new XMLDBTable('changeme');
$table->setComment('Default comment for the table, please edit me');
$table->addField($field);
$table->addKey($key);
/// Finally, add the whole retroffited 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;
}
示例5: xmldb_main_upgrade
//.........这里部分代码省略.........
$table->comment = 'A service is a group of functions';
// fields
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$f = $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('description', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('apiversion', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('offer', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
// Create the table
$result = $result && create_table($table);
$table = new XMLDBTable('mnet_service2rpc');
$table->comment = 'Group functions or methods under a service';
// fields
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$f = $table->addFieldInfo('serviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('rpcid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('unique', XMLDB_INDEX_UNIQUE, array('rpcid', 'serviceid'));
// Create the table
$result = $result && create_table($table);
//
// Prime MNET configuration entries -- will be needed later by auth/mnet
//
include_once $CFG->dirroot . '/mnet/lib.php';
$env = new mnet_environment();
$env->init();
unset($env);
// add mnethostid to user-
$table = new XMLDBTable('user');
$field = new XMLDBField('mnethostid');
$field->setType(XMLDB_TYPE_INTEGER);
$field->setLength(10);
$field->setNotNull(true);
$field->setSequence(null);
$field->setEnum(null);
$field->setDefault('0');
$field->setPrevious("deleted");
$field->setNext("username");
$result = $result && add_field($table, $field);
// The default mnethostid is zero... we need to update this for all
// users of the local IdP service.
set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'mnethostid', '0');
$index = new XMLDBIndex('username');
$index->setUnique(true);
$index->setFields(array('username'));
drop_index($table, $index);
$index->setFields(array('mnethostid', 'username'));
if (!add_index($table, $index)) {
notify(get_string('duplicate_usernames', 'mnet', 'http://docs.moodle.org/en/DuplicateUsernames'));
}
unset($table, $field, $index);
/**
** auth/mnet tables
**/
$table = new XMLDBTable('mnet_session');
$table->comment = 'Store session data from users migrating to other sites';
// fields
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$f = $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('token', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('mnethostid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('useragent', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('confirm_timeout', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);