本文整理汇总了PHP中XMLDBField::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBField::getName方法的具体用法?PHP XMLDBField::getName怎么用?PHP XMLDBField::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDBField
的用法示例。
在下文中一共展示了XMLDBField::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRenameTableExtraSQL
/**
* Returns the code (array of statements) needed to execute extra statements on table rename
*/
function getRenameTableExtraSQL($xmldb_table, $newname)
{
$results = array();
$xmldb_field = new XMLDBField('id');
// Fields having sequences should be exclusively, id.
$oldseqname = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'seq');
$newseqname = $this->getNameForObject($newname, $xmldb_field->getName(), 'seq');
/// Rename de sequence
$results[] = 'RENAME ' . $oldseqname . ' TO ' . $newseqname;
$oldtriggername = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'trg');
$newtriggername = $this->getNameForObject($newname, $xmldb_field->getName(), 'trg');
/// Drop old trigger
$results[] = "DROP TRIGGER " . $oldtriggername;
$newt = new XMLDBTable($newname);
/// Temp table for trigger code generation
/// Create new trigger
$results = array_merge($results, $this->getCreateTriggerSQL($newt, $xmldb_field));
/// Rename all the check constraints in the table
$oldtablename = $this->getTableName($xmldb_table);
$newtablename = $this->getTableName($newt);
$oldconstraintprefix = $this->getNameForObject($xmldb_table->getName(), '');
$newconstraintprefix = $this->getNameForObject($newt->getName(), '', '');
if ($constraints = $this->getCheckConstraintsFromDB($xmldb_table)) {
foreach ($constraints as $constraint) {
/// Drop the old constraint
$results[] = 'ALTER TABLE ' . $newtablename . ' DROP CONSTRAINT ' . $constraint->name;
/// Calculate the new constraint name
$newconstraintname = str_replace($oldconstraintprefix, $newconstraintprefix, $constraint->name);
/// Add the new constraint
$results[] = 'ALTER TABLE ' . $newtablename . ' ADD CONSTRAINT ' . $newconstraintname . ' CHECK (' . $constraint->description . ')';
}
}
return $results;
}