本文整理汇总了PHP中XMLDBField::arr2XMLDBField方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBField::arr2XMLDBField方法的具体用法?PHP XMLDBField::arr2XMLDBField怎么用?PHP XMLDBField::arr2XMLDBField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDBField
的用法示例。
在下文中一共展示了XMLDBField::arr2XMLDBField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim
/**
* Load data from XML to the table
*/
function arr2XMLDBTable($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 XMLDBField($name);
$field->arr2XMLDBField($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 XMLDBKey($name);
$key->arr2XMLDBKey($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);
//.........这里部分代码省略.........