当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractPlatform::getPreAlterTableIndexForeignKeySQL方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::getPreAlterTableIndexForeignKeySQL方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPlatform::getPreAlterTableIndexForeignKeySQL方法的具体用法?PHP AbstractPlatform::getPreAlterTableIndexForeignKeySQL怎么用?PHP AbstractPlatform::getPreAlterTableIndexForeignKeySQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Platforms\AbstractPlatform的用法示例。


在下文中一共展示了AbstractPlatform::getPreAlterTableIndexForeignKeySQL方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPreAlterTableIndexForeignKeySQL

 /**
  * {@inheritDoc}
  */
 protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
 {
     $sql = array();
     $table = $diff->name;
     foreach ($diff->removedIndexes as $remKey => $remIndex) {
         foreach ($diff->addedIndexes as $addKey => $addIndex) {
             if ($remIndex->getColumns() == $addIndex->getColumns()) {
                 $type = '';
                 if ($addIndex->isUnique()) {
                     $type = 'UNIQUE ';
                 }
                 $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', ';
                 $query .= 'ADD ' . $type . 'INDEX ' . $addIndex->getName();
                 $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex->getQuotedColumns($this)) . ')';
                 $sql[] = $query;
                 unset($diff->removedIndexes[$remKey]);
                 unset($diff->addedIndexes[$addKey]);
                 break;
             }
         }
     }
     $sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));
     return $sql;
 }
开发者ID:trangunghoa,项目名称:l4cms,代码行数:27,代码来源:MySqlPlatform.php

示例2: getPreAlterTableIndexForeignKeySQL

 /**
  * {@inheritDoc}
  */
 protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
 {
     $sql = array();
     $table = $diff->getName()->getQuotedName($this);
     foreach ($diff->removedIndexes as $remKey => $remIndex) {
         // Dropping primary keys requires to unset autoincrement attribute on the particular column first.
         if ($remIndex->isPrimary() && $diff->fromTable instanceof Table) {
             foreach ($remIndex->getColumns() as $columnName) {
                 $column = $diff->fromTable->getColumn($columnName);
                 if ($column->getAutoincrement() === true) {
                     $column->setAutoincrement(false);
                     $sql[] = 'ALTER TABLE ' . $table . ' MODIFY ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
                 }
             }
         }
         foreach ($diff->addedIndexes as $addKey => $addIndex) {
             if ($remIndex->getColumns() == $addIndex->getColumns()) {
                 $indexClause = 'INDEX ' . $addIndex->getName();
                 if ($addIndex->isPrimary()) {
                     $indexClause = 'PRIMARY KEY';
                 } elseif ($addIndex->isUnique()) {
                     $indexClause = 'UNIQUE INDEX ' . $addIndex->getName();
                 }
                 $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', ';
                 $query .= 'ADD ' . $indexClause;
                 $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex->getQuotedColumns($this)) . ')';
                 $sql[] = $query;
                 unset($diff->removedIndexes[$remKey]);
                 unset($diff->addedIndexes[$addKey]);
                 break;
             }
         }
     }
     $engine = 'INNODB';
     if ($diff->fromTable instanceof Table && $diff->fromTable->hasOption('engine')) {
         $engine = strtoupper(trim($diff->fromTable->getOption('engine')));
     }
     // Suppress foreign key constraint propagation on non-supporting engines.
     if ('INNODB' !== $engine) {
         $diff->addedForeignKeys = array();
         $diff->changedForeignKeys = array();
         $diff->removedForeignKeys = array();
     }
     $sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));
     return $sql;
 }
开发者ID:tamboer,项目名称:LaravelOctober,代码行数:49,代码来源:MySqlPlatform.php

示例3: getPreAlterTableIndexForeignKeySQL

 /**
  * {@inheritDoc}
  */
 protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
 {
     $sql = array();
     $table = $diff->getName($this)->getQuotedName($this);
     foreach ($diff->removedIndexes as $remKey => $remIndex) {
         foreach ($diff->addedIndexes as $addKey => $addIndex) {
             if ($remIndex->getColumns() == $addIndex->getColumns()) {
                 if ($remIndex->isPrimary()) {
                     $sql[] = 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY';
                 } elseif ($remIndex->isUnique()) {
                     $sql[] = 'ALTER TABLE ' . $table . ' DROP UNIQUE ' . $remIndex->getQuotedName($this);
                 } else {
                     $sql[] = $this->getDropIndexSQL($remIndex, $table);
                 }
                 $sql[] = $this->getCreateIndexSQL($addIndex, $table);
                 unset($diff->removedIndexes[$remKey]);
                 unset($diff->addedIndexes[$addKey]);
                 break;
             }
         }
     }
     $sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));
     return $sql;
 }
开发者ID:doctrine,项目名称:dbal,代码行数:27,代码来源:DB2Platform.php

示例4: getPreAlterTableIndexForeignKeySQL

 /**
  * {@inheritDoc}
  */
 protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
 {
     $sql = array();
     $table = $diff->getName($this)->getQuotedName($this);
     foreach ($diff->changedIndexes as $changedIndex) {
         $sql = array_merge($sql, $this->getPreAlterTableAlterPrimaryKeySQL($diff, $changedIndex));
     }
     foreach ($diff->removedIndexes as $remKey => $remIndex) {
         $sql = array_merge($sql, $this->getPreAlterTableAlterPrimaryKeySQL($diff, $remIndex));
         foreach ($diff->addedIndexes as $addKey => $addIndex) {
             if ($remIndex->getColumns() == $addIndex->getColumns()) {
                 $indexClause = 'INDEX ' . $addIndex->getName();
                 if ($addIndex->isPrimary()) {
                     $indexClause = 'PRIMARY KEY';
                 } elseif ($addIndex->isUnique()) {
                     $indexClause = 'UNIQUE INDEX ' . $addIndex->getName();
                 }
                 $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', ';
                 $query .= 'ADD ' . $indexClause;
                 $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex->getQuotedColumns($this)) . ')';
                 $sql[] = $query;
                 unset($diff->removedIndexes[$remKey]);
                 unset($diff->addedIndexes[$addKey]);
                 break;
             }
         }
     }
     $engine = 'INNODB';
     if ($diff->fromTable instanceof Table && $diff->fromTable->hasOption('engine')) {
         $engine = strtoupper(trim($diff->fromTable->getOption('engine')));
     }
     // Suppress foreign key constraint propagation on non-supporting engines.
     if ('INNODB' !== $engine) {
         $diff->addedForeignKeys = array();
         $diff->changedForeignKeys = array();
         $diff->removedForeignKeys = array();
     }
     $sql = array_merge($sql, $this->getPreAlterTableAlterIndexForeignKeySQL($diff), parent::getPreAlterTableIndexForeignKeySQL($diff), $this->getPreAlterTableRenameIndexForeignKeySQL($diff));
     return $sql;
 }
开发者ID:doctrine,项目名称:dbal,代码行数:43,代码来源:MySqlPlatform.php

示例5: getPreAlterTableIndexForeignKeySQL

 /**
  * {@inheritDoc}
  */
 protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
 {
     $sql = array();
     $table = $diff->name;
     foreach ($diff->changedIndexes as $changedKey => $changedIndex) {
         $sql[] = $this->getDropConstraintSQL('IF EXISTS ' . $changedIndex->getName(), $table);
         $sql[] = $this->getDropIndexSQL('IF EXISTS ' . $changedIndex->getName(), $table);
         $diff->addedIndexes[$changedKey] = $diff->changedIndexes[$changedKey];
         unset($diff->changedIndexes[$changedKey]);
     }
     $sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));
     return $sql;
 }
开发者ID:anolisti,项目名称:3rdparty,代码行数:16,代码来源:PostgreSqlPlatform.php

示例6: getPreAlterTableIndexForeignKeySQL

 /**
  * {@inheritDoc}
  */
 protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
 {
     $sql = array();
     $table = $diff->name;
     foreach ($diff->removedIndexes as $remKey => $remIndex) {
         // Dropping primary keys requires to unset autoincrement attribute on the particular column first.
         if ($remIndex->isPrimary() && $diff->fromTable instanceof Table) {
             foreach ($remIndex->getColumns() as $columnName) {
                 $column = $diff->fromTable->getColumn($columnName);
                 if ($column->getAutoincrement() === true) {
                     $column->setAutoincrement(false);
                     $sql[] = 'ALTER TABLE ' . $table . ' MODIFY ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
                     // original autoincrement information might be needed later on by other parts of the table alteration
                     $column->setAutoincrement(true);
                 }
             }
         }
         foreach ($diff->addedIndexes as $addKey => $addIndex) {
             if ($remIndex->getColumns() == $addIndex->getColumns()) {
                 $indexClause = 'INDEX ' . $addIndex->getName();
                 if ($addIndex->isPrimary()) {
                     $indexClause = 'PRIMARY KEY';
                 } elseif ($addIndex->isUnique()) {
                     $indexClause = 'UNIQUE INDEX ' . $addIndex->getName();
                 }
                 $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', ';
                 $query .= 'ADD ' . $indexClause;
                 $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex->getQuotedColumns($this)) . ')';
                 $sql[] = $query;
                 unset($diff->removedIndexes[$remKey]);
                 unset($diff->addedIndexes[$addKey]);
                 break;
             }
         }
     }
     $sql = array_merge($sql, $this->getPreAlterTableAlterIndexForeignKeySQL($diff), parent::getPreAlterTableIndexForeignKeySQL($diff));
     return $sql;
 }
开发者ID:jacke121,项目名称:tdbasset,代码行数:41,代码来源:MySqlPlatform.php

示例7: getPreAlterTableIndexForeignKeySQL

 /**
  * {@inheritDoc}
  */
 protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
 {
     $sql = array();
     $table = $diff->name;
     foreach ($diff->removedIndexes as $remKey => $remIndex) {
         foreach ($diff->addedIndexes as $addKey => $addIndex) {
             if ($remIndex->getColumns() == $addIndex->getColumns()) {
                 $columns = $addIndex->getColumns();
                 $type = '';
                 if ($addIndex->isUnique()) {
                     $type = 'UNIQUE ';
                 }
                 $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', ';
                 $query .= 'ADD ' . $type . 'INDEX ' . $addIndex->getName();
                 $query .= ' (' . $this->getIndexFieldDeclarationListSQL($columns) . ')';
                 $sql[] = $query;
                 unset($diff->removedIndexes[$remKey]);
                 unset($diff->addedIndexes[$addKey]);
                 break;
             }
         }
     }
     foreach ($diff->changedIndexes as $changedKey => $changedIndex) {
         if ($changedIndex->isPrimary() && $changedKey != 'PRIMARY') {
             $index = $diff->changedIndexes[$changedKey];
             $index = new index($changedKey, $index->getColumns(), $index->isUnique(), false);
             $diff->removedIndexes[$changedKey] = $index;
             $diff->addedIndexes['PRIMARY'] = $diff->changedIndexes[$changedKey];
             unset($diff->changedIndexes[$changedKey]);
         }
     }
     $sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));
     return $sql;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:37,代码来源:MySqlPlatform.php


注:本文中的Doctrine\DBAL\Platforms\AbstractPlatform::getPreAlterTableIndexForeignKeySQL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。