本文整理汇总了PHP中xmldb_field::setChanged方法的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_field::setChanged方法的具体用法?PHP xmldb_field::setChanged怎么用?PHP xmldb_field::setChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmldb_field
的用法示例。
在下文中一共展示了xmldb_field::setChanged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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->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;
}
示例2: addField
/**
* Add one field to the table, allowing to specify the desired order
* If it's not specified, then the field is added at the end
* @param xmldb_field $field
* @param xmldb_object $after
* @return xmldb_field
*/
public function addField($field, $after = null)
{
// Detect duplicates first
if ($this->getField($field->getName())) {
throw new coding_exception('Duplicate field ' . $field->getName() . ' specified in table ' . $this->getName());
}
// Calculate the previous and next fields
$prevfield = null;
$nextfield = null;
if (!$after) {
$allfields = $this->getFields();
if (!empty($allfields)) {
end($allfields);
$prevfield = $allfields[key($allfields)];
}
} else {
$prevfield = $this->getField($after);
}
if ($prevfield && $prevfield->getNext()) {
$nextfield = $this->getField($prevfield->getNext());
}
// Set current field previous and next attributes
if ($prevfield) {
$field->setPrevious($prevfield->getName());
$prevfield->setNext($field->getName());
}
if ($nextfield) {
$field->setNext($nextfield->getName());
$nextfield->setPrevious($field->getName());
}
// Some more attributes
$field->setLoaded(true);
$field->setChanged(true);
// Add the new field
$this->fields[] = $field;
// Reorder the field
$this->orderFields($this->fields);
// Recalculate the hash
$this->calculateHash(true);
// We have one new field, so the table has changed
$this->setChanged(true);
return $field;
}