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


PHP AbstractPlatform::getCreateIndexSQL方法代码示例

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


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

示例1: testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes

 public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes()
 {
     $where = 'test IS NULL AND test2 IS NOT NULL';
     $indexDef = new \Doctrine\DBAL\Schema\Index('name', array('test', 'test2'), false, false, array(), array('where' => $where));
     $uniqueIndex = new \Doctrine\DBAL\Schema\Index('name', array('test', 'test2'), true, false, array(), array('where' => $where));
     $expected = ' WHERE ' . $where;
     $actuals = array();
     if ($this->supportsInlineIndexDeclaration()) {
         $actuals[] = $this->_platform->getIndexDeclarationSQL('name', $indexDef);
     }
     $actuals[] = $this->_platform->getUniqueConstraintDeclarationSQL('name', $uniqueIndex);
     $actuals[] = $this->_platform->getCreateIndexSQL($indexDef, 'table');
     foreach ($actuals as $actual) {
         if ($this->_platform->supportsPartialIndexes()) {
             $this->assertStringEndsWith($expected, $actual, 'WHERE clause should be present');
         } else {
             $this->assertStringEndsNotWith($expected, $actual, 'WHERE clause should NOT be present');
         }
     }
 }
开发者ID:selimcr,项目名称:servigases,代码行数:20,代码来源:AbstractPlatformTestCase.php

示例2: getCreateIndexSQL

 /**
  * {@inheritdoc}
  *
  * Appends SQL Anywhere specific flags if given.
  */
 public function getCreateIndexSQL(Index $index, $table)
 {
     return parent::getCreateIndexSQL($index, $table) . $this->getAdvancedIndexOptionsSQL($index);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:9,代码来源:SQLAnywherePlatform.php

示例3: createIndex

 /**
  * Create a new index on a table
  *
  * @param Index     $index
  * @param string    $table         name of the table on which the index is to be created
  */
 public function createIndex(Index $index, $table)
 {
     $this->_execSql($this->_platform->getCreateIndexSQL($index, $table));
 }
开发者ID:jff15,项目名称:travelbot,代码行数:10,代码来源:AbstractSchemaManager.php

示例4: getCreateIndexSQL

 /**
  * {@inheritDoc}
  */
 public function getCreateIndexSQL(Index $index, $table)
 {
     $constraint = parent::getCreateIndexSQL($index, $table);
     if ($index->isUnique() && !$index->isPrimary()) {
         $constraint = $this->_appendUniqueConstraintDefinition($constraint, $index);
     }
     return $constraint;
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:11,代码来源:SQLServerPlatform.php

示例5: backupExistingSchema

 /**
  * @param $tables
  * @param $backupPrefix
  *
  * @return array
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 protected function backupExistingSchema($tables, $mauticTables, $backupPrefix)
 {
     $sql = [];
     $sm = $this->db->getSchemaManager();
     //backup existing tables
     $backupRestraints = $backupSequences = $backupIndexes = $backupTables = $dropSequences = $dropTables = [];
     //cycle through the first time to drop all the foreign keys
     foreach ($tables as $t) {
         if (!isset($mauticTables[$t]) && !in_array($t, $mauticTables)) {
             // Not an applicable table
             continue;
         }
         $restraints = $sm->listTableForeignKeys($t);
         if (isset($mauticTables[$t])) {
             //to be backed up
             $backupRestraints[$mauticTables[$t]] = $restraints;
             $backupTables[$t] = $mauticTables[$t];
             $backupIndexes[$t] = $sm->listTableIndexes($t);
         } else {
             //existing backup to be dropped
             $dropTables[] = $t;
         }
         foreach ($restraints as $restraint) {
             $sql[] = $this->platform->getDropForeignKeySQL($restraint, $t);
         }
     }
     //now drop all the backup tables
     foreach ($dropTables as $t) {
         $sql[] = $this->platform->getDropTableSQL($t);
     }
     //now backup tables
     foreach ($backupTables as $t => $backup) {
         //drop old indexes
         /** @var \Doctrine\DBAL\Schema\Index $oldIndex */
         foreach ($backupIndexes[$t] as $indexName => $oldIndex) {
             if ($indexName == 'primary') {
                 continue;
             }
             $oldName = $oldIndex->getName();
             $newName = $this->generateBackupName($this->dbParams['table_prefix'], $backupPrefix, $oldName);
             $newIndex = new Index($newName, $oldIndex->getColumns(), $oldIndex->isUnique(), $oldIndex->isPrimary(), $oldIndex->getFlags());
             $newIndexes[] = $newIndex;
             $sql[] = $this->platform->getDropIndexSQL($oldIndex, $t);
         }
         //rename table
         $tableDiff = new TableDiff($t);
         $tableDiff->newName = $backup;
         $queries = $this->platform->getAlterTableSQL($tableDiff);
         $sql = array_merge($sql, $queries);
         //create new index
         if (!empty($newIndexes)) {
             foreach ($newIndexes as $newIndex) {
                 $sql[] = $this->platform->getCreateIndexSQL($newIndex, $backup);
             }
             unset($newIndexes);
         }
     }
     //apply foreign keys to backup tables
     foreach ($backupRestraints as $table => $oldRestraints) {
         foreach ($oldRestraints as $or) {
             $foreignTable = $or->getForeignTableName();
             $foreignTableName = $this->generateBackupName($this->dbParams['table_prefix'], $backupPrefix, $foreignTable);
             $r = new ForeignKeyConstraint($or->getLocalColumns(), $foreignTableName, $or->getForeignColumns(), $backupPrefix . $or->getName(), $or->getOptions());
             $sql[] = $this->platform->getCreateForeignKeySQL($r, $table);
         }
     }
     return $sql;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:76,代码来源:SchemaHelper.php

示例6: testGeneratesUniqueIndexCreationSql

 public function testGeneratesUniqueIndexCreationSql()
 {
     $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true);
     $sql = $this->_platform->getCreateIndexSQL($indexDef, 'test');
     $this->assertEquals($this->getGenerateUniqueIndexSql(), $sql);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:6,代码来源:AbstractPlatformTestCase.php


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