本文整理汇总了PHP中Doctrine\DBAL\Schema\Table::getPrimaryKeyColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::getPrimaryKeyColumns方法的具体用法?PHP Table::getPrimaryKeyColumns怎么用?PHP Table::getPrimaryKeyColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\Table
的用法示例。
在下文中一共展示了Table::getPrimaryKeyColumns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renameOneToManyExtendField
protected function renameOneToManyExtendField(Schema $schema, QueryBag $queries, Table $table, $associationName, $targetEntityClassName, EntityMetadataHelper $entityMetadataHelper)
{
$entityClassName = $entityMetadataHelper->getEntityClassByTableName($table->getName());
$targetTableName = $entityMetadataHelper->getTableNameByEntityClass($targetEntityClassName);
if ($schema->hasTable($targetTableName)) {
$targetTable = $schema->getTable($targetTableName);
$oldTargetColumnName = sprintf('field_%s_%s_id', strtolower(ExtendHelper::getShortClassName($entityClassName)), $associationName);
if ($targetTable->hasColumn($oldTargetColumnName)) {
$newTargetColumnName = $this->nameGenerator->generateOneToManyRelationColumnName($entityClassName, $associationName);
$oldIndexName = $this->nameGenerator->generateIndexName($targetTableName, [$oldTargetColumnName], false, true);
if ($targetTable->hasIndex($oldIndexName)) {
$targetTable->dropIndex($oldIndexName);
}
$oldForeignKeyName = $this->nameGenerator->generateForeignKeyConstraintName($targetTableName, [$oldTargetColumnName], true);
if ($targetTable->hasForeignKey($oldForeignKeyName)) {
$targetTable->removeForeignKey($oldForeignKeyName);
}
$this->renameExtension->renameColumn($schema, $queries, $targetTable, $oldTargetColumnName, $newTargetColumnName);
$this->renameExtension->addIndex($schema, $queries, $targetTable->getName(), [$newTargetColumnName]);
$this->renameExtension->addForeignKeyConstraint($schema, $queries, $targetTable->getName(), $table->getName(), [$newTargetColumnName], $table->getPrimaryKeyColumns(), ['onDelete' => 'SET NULL']);
}
}
}