本文整理汇总了PHP中ForeignKey::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey::getName方法的具体用法?PHP ForeignKey::getName怎么用?PHP ForeignKey::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDropForeignKeyDDL
public function getDropForeignKeyDDL(ForeignKey $fk)
{
if ($fk->isSkipSql()) {
return;
}
$pattern = "\nALTER TABLE %s DROP FOREIGN KEY %s;\n";
return sprintf($pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->quoteIdentifier($fk->getName()));
}
示例2: getForeignKeyDDL
public function getForeignKeyDDL(ForeignKey $fk)
{
if ($fk->isSkipSql()) {
return;
}
$pattern = 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)';
$script = sprintf($pattern, $this->quoteIdentifier($fk->getName()), $this->getColumnListDDL($fk->getLocalColumns()), $this->quoteIdentifier($fk->getForeignTableName()), $this->getColumnListDDL($fk->getForeignColumns()));
if ($fk->hasOnUpdate() && $fk->getOnUpdate() != ForeignKey::SETNULL) {
$script .= ' ON UPDATE ' . $fk->getOnUpdate();
}
if ($fk->hasOnDelete() && $fk->getOnDelete() != ForeignKey::SETNULL) {
$script .= ' ON DELETE ' . $fk->getOnDelete();
}
return $script;
}
示例3: parse
/**
* @param string $stmt
* @return $this
*/
public function parse($stmt)
{
$lines = array_map('trim', explode(PHP_EOL, $stmt));
$this->first = array_shift($lines);
$last = array_pop($lines);
//remove AUTO_INCREMENT bit from raw statement
$this->last = preg_replace('/AUTO_INCREMENT=\\d+ ?/', '', $last);
$this->statement = str_replace($last, $this->last, $stmt);
if ($this->name === null) {
if (!preg_match('/`([^`]+)/', $this->first, $match)) {
throw new \RuntimeException(sprintf('Unable to extract name from %s (looked at line %s)', $stmt, $lines[0]));
}
$this->name = $match[1];
}
foreach ($lines as $ln) {
if (mb_substr($ln, -1) == ',') {
$ln = mb_substr($ln, 0, -1);
}
//field lines start with back-tick
switch ($ln[0]) {
case '`':
$field = new Field($ln);
$this->fields[$field->getName()] = $field;
break;
case 'P':
$this->primary = new Primary($ln);
break;
case 'S':
//spatial
//spatial
case 'U':
//unique
//unique
case 'F':
//fulltext
//fulltext
case 'I':
//index
//index
case 'K':
//Key
$idx = new Index($ln);
$this->indexes[$idx->getName()] = $idx;
break;
case 'C':
$constraint = new ForeignKey($ln);
$this->constraints[$constraint->getName()] = $constraint;
break;
default:
throw new \LogicException(sprintf('Unable to parse line %s in %s', $ln, $stmt));
}
}
return $this;
}
示例4: getForeignKeyDDL
public function getForeignKeyDDL(ForeignKey $fk)
{
if ($fk->isSkipSql()) {
return;
}
$pattern = "CONSTRAINT %s\r\n FOREIGN KEY (%s) REFERENCES %s (%s)";
$script = sprintf($pattern, $this->quoteIdentifier($fk->getName()), $this->getColumnListDDL($fk->getLocalColumns()), $this->quoteIdentifier($fk->getForeignTableName()), $this->getColumnListDDL($fk->getForeignColumns()));
if ($fk->hasOnDelete()) {
$script .= "\r\n ON DELETE " . $fk->getOnDelete();
}
return $script;
}
示例5: addForeignKey
/**
* @param ForeignKey $foreignKey
*/
public function addForeignKey(ForeignKey $foreignKey)
{
$foreignKey->setParentTable($this);
$this->foreignKeys[$foreignKey->getName()] = $foreignKey;
}
示例6: addChangedForeignKey
/**
* @param ForeignKey $changedForeignKey
*/
public function addChangedForeignKey(ForeignKey $changedForeignKey)
{
$this->changedForeignKeys[$changedForeignKey->getName()] = $changedForeignKey;
}