本文整理汇总了PHP中XMLDBIndex::setFromADOIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBIndex::setFromADOIndex方法的具体用法?PHP XMLDBIndex::setFromADOIndex怎么用?PHP XMLDBIndex::setFromADOIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDBIndex
的用法示例。
在下文中一共展示了XMLDBIndex::setFromADOIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invoke
//.........这里部分代码省略.........
if (!$tableparam) {
/// No postaction here
$this->postaction = NULL;
/// Get list of tables
$dbtables = $db->MetaTables('TABLES');
$selecttables = array();
foreach ($dbtables as $dbtable) {
$dbtable = strtolower(str_replace($CFG->prefix, '', $dbtable));
$i = $structure->findTableInArray($dbtable);
if ($i === NULL) {
$selecttables[$dbtable] = $dbtable;
}
}
/// Get list of after tables
$aftertables = array();
if ($tables =& $structure->getTables()) {
foreach ($tables as $aftertable) {
$aftertables[$aftertable->getName()] = $aftertable->getName();
}
}
if (!$selecttables) {
$this->errormsg = 'No tables available to be retrofitted';
return false;
}
/// Now build the form
$o = '<form id="form" action="index.php" method="post">';
$o .= '<div>';
$o .= ' <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />';
$o .= ' <input type="hidden" name ="action" value="new_table_from_mysql" />';
$o .= ' <input type="hidden" name ="postaction" value="edit_table" />';
$o .= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
$o .= ' <tr><td><label for="table" accesskey="t">' . $this->str['createtable'] . ' </label>' . choose_from_menu($selecttables, 'table', '', 'choose', '', 0, true) . '<label for="after" accesskey="a">' . $this->str['aftertable'] . ' </label>' . choose_from_menu($aftertables, 'after', '', 'choose', '', 0, true) . '</td></tr>';
$o .= ' <tr><td colspan="2" align="center"><input type="submit" value="' . $this->str['create'] . '" /></td></tr>';
$o .= ' <tr><td colspan="2" align="center"><a href="index.php?action=edit_xml_file&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a></td></tr>';
$o .= ' </table>';
$o .= '</div></form>';
$this->output = $o;
/// If table, retrofit information and, if everything works,
/// go to the table edit action
} else {
/// Get some params (table is mandatory here)
$tableparam = required_param('table', PARAM_CLEAN);
$afterparam = required_param('after', PARAM_CLEAN);
/// Create one new XMLDBTable
$table = new XMLDBTable(strtolower(trim($tableparam)));
$table->setComment($table->getName() . ' table retrofitted from MySQL');
/// Get fields info from ADODb
if (!($dbfields = $db->MetaColumns($CFG->prefix . $tableparam))) {
///Try it without prefix if doesn't exist
$dbfields = $db->MetaColumns($tableparam);
}
if ($dbfields) {
foreach ($dbfields as $dbfield) {
/// Create new XMLDB field
$field = new XMLDBField(strtolower($dbfield->name));
/// Set field with info retrofitted
$field->setFromADOField($dbfield);
/// Add field to the table
$table->addField($field);
}
}
/// Get PK, UK and indexes info from ADODb
$dbindexes = $db->MetaIndexes($CFG->prefix . $tableparam, true);
if ($dbindexes) {
$lastkey = NULL;
//To temp store the last key processed
foreach ($dbindexes as $indexname => $dbindex) {
/// Add the indexname to the array
$dbindex['name'] = $indexname;
/// We are handling one XMLDBKey (primaries + uniques)
if ($dbindex['unique']) {
$key = new XMLDBKey(strtolower($dbindex['name']));
/// Set key with info retrofitted
$key->setFromADOKey($dbindex);
/// Set default comment to PKs
if ($key->getType() == XMLDB_KEY_PRIMARY) {
}
/// Add key to the table
$table->addKey($key);
/// We are handling one XMLDBIndex (non-uniques)
} else {
$index = new XMLDBIndex(strtolower($dbindex['name']));
/// Set index with info retrofitted
$index->setFromADOIndex($dbindex);
/// Add index to the table
$table->addIndex($index);
}
}
}
/// Finally, add the whole retroffited table to the structure
/// in the place specified
$structure->addTable($table, $afterparam);
}
/// Launch postaction if exists (leave this here!)
if ($this->getPostAction() && $result) {
return $this->launch($this->getPostAction());
}
/// Return ok if arrived here
return $result;
}