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


PHP Schema::hasSequence方法代码示例

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


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

示例1: down

 /**
  * Down method
  *
  * @param Schema $schema
  */
 public function down(Schema $schema)
 {
     if (Version::isSupportGetInstanceFunction()) {
         $app = Application::getInstance();
         $meta = $this->getMetadata($app['orm.em']);
         $tool = new SchemaTool($app['orm.em']);
         $schemaFromMetadata = $tool->getSchemaFromMetadata($meta);
         // テーブル削除
         foreach ($schemaFromMetadata->getTables() as $table) {
             if ($schema->hasTable($table->getName())) {
                 $schema->dropTable($table->getName());
             }
         }
         // シーケンス削除
         foreach ($schemaFromMetadata->getSequences() as $sequence) {
             if ($schema->hasSequence($sequence->getName())) {
                 $schema->dropSequence($sequence->getName());
             }
         }
     } else {
         if ($schema->hasTable(self::MAKER)) {
             $schema->dropTable(self::MAKER);
         }
         if ($schema->hasTable(self::PRODUCTMAKER)) {
             $schema->dropTable(self::PRODUCTMAKER);
         }
     }
     if ($this->connection->getDatabasePlatform()->getName() == 'postgresql') {
         foreach ($this->sequence as $sequence) {
             if ($schema->hasSequence($sequence)) {
                 $schema->dropSequence($sequence);
             }
         }
     }
 }
开发者ID:EC-CUBE,项目名称:maker-plugin,代码行数:40,代码来源:Version201507231300.php

示例2: down

 /**
  * remove table.
  *
  * @param Schema $schema
  */
 public function down(Schema $schema)
 {
     //current version >= 3.0.9
     if (Version::isSupportGetInstanceFunction()) {
         $app = Application::getInstance();
         $meta = $this->getMetadata($app['orm.em']);
         $tool = new SchemaTool($app['orm.em']);
         $schemaFromMetadata = $tool->getSchemaFromMetadata($meta);
         // テーブル削除
         foreach ($schemaFromMetadata->getTables() as $table) {
             if ($schema->hasTable($table->getName())) {
                 $schema->dropTable($table->getName());
             }
         }
         // シーケンス削除
         foreach ($schemaFromMetadata->getSequences() as $sequence) {
             if ($schema->hasSequence($sequence->getName())) {
                 $schema->dropSequence($sequence->getName());
             }
         }
         //for delete sequence in postgresql
         if ($this->connection->getDatabasePlatform()->getName() == 'postgresql') {
             $schema->dropSequence('plg_related_product_id_seq');
         }
     } else {
         // this down() migration is auto-generated, please modify it to your needs
         $schema->dropTable(self::NAME);
         $schema->dropSequence('plg_related_product_id_seq');
     }
 }
开发者ID:EC-CUBE,项目名称:related-product-plugin,代码行数:35,代码来源:Version20150808173000.php

示例3: down

 /**
  * Remove data.
  *
  * @param Schema $schema
  */
 public function down(Schema $schema)
 {
     if (Version::isSupportGetInstanceFunction()) {
         $app = Application::getInstance();
         $meta = $this->getMetadata($app['orm.em']);
         $tool = new SchemaTool($app['orm.em']);
         $schemaFromMetadata = $tool->getSchemaFromMetadata($meta);
         // テーブル削除
         foreach ($schemaFromMetadata->getTables() as $table) {
             if ($schema->hasTable($table->getName())) {
                 $schema->dropTable($table->getName());
             }
         }
         // シーケンス削除
         foreach ($schemaFromMetadata->getSequences() as $sequence) {
             if ($schema->hasSequence($sequence->getName())) {
                 $schema->dropSequence($sequence->getName());
             }
         }
     } else {
         // this down() migration is auto-generated, please modify it to your needs
         $schema->dropTable(self::NAME);
         $schema->dropSequence('plg_recommend_product_recommend_product_id_seq');
     }
 }
开发者ID:EC-CUBE,项目名称:Recommend-plugin,代码行数:30,代码来源:Version201510211300.php

示例4: up

 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     if ($this->connection->getDatabasePlatform()->getName() == "postgresql") {
         if ($schema->hasSequence('dtb_base_info_id_seq')) {
             $this->addSql("SELECT setval('dtb_base_info_id_seq', 2);");
         }
     }
 }
开发者ID:geany-y,项目名称:LikeNiko,代码行数:11,代码来源:Version20151016145841.php

示例5: up

 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     foreach ($this->targetTables as $table) {
         if ($schema->hasTable($table)) {
             $schema->dropTable($table);
         }
     }
     if ($this->connection->getDatabasePlatform()->getName() == "postgresql") {
         foreach ($this->targetSequences as $seq) {
             if ($schema->hasSequence($seq)) {
                 $schema->dropSequence($seq);
             }
         }
     }
 }
开发者ID:hiroyasu55,项目名称:ec-cube,代码行数:18,代码来源:Version20150805105421.php

示例6: compare

 /**
  * Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
  *
  * The returned differences are returned in such a way that they contain the
  * operations to change the schema stored in $fromSchema to the schema that is
  * stored in $toSchema.
  *
  * @param \Doctrine\DBAL\Schema\Schema $fromSchema
  * @param \Doctrine\DBAL\Schema\Schema $toSchema
  *
  * @return \Doctrine\DBAL\Schema\SchemaDiff
  */
 public function compare(Schema $fromSchema, Schema $toSchema)
 {
     $diff = new SchemaDiff();
     $diff->fromSchema = $fromSchema;
     $foreignKeysToTable = array();
     foreach ($toSchema->getNamespaces() as $namespace) {
         if (!$fromSchema->hasNamespace($namespace)) {
             $diff->newNamespaces[$namespace] = $namespace;
         }
     }
     foreach ($fromSchema->getNamespaces() as $namespace) {
         if (!$toSchema->hasNamespace($namespace)) {
             $diff->removedNamespaces[$namespace] = $namespace;
         }
     }
     foreach ($toSchema->getTables() as $table) {
         $tableName = $table->getShortestName($toSchema->getName());
         if (!$fromSchema->hasTable($tableName)) {
             $diff->newTables[$tableName] = $toSchema->getTable($tableName);
         } else {
             $tableDifferences = $this->diffTable($fromSchema->getTable($tableName), $toSchema->getTable($tableName));
             if ($tableDifferences !== false) {
                 $diff->changedTables[$tableName] = $tableDifferences;
             }
         }
     }
     /* Check if there are tables removed */
     foreach ($fromSchema->getTables() as $table) {
         $tableName = $table->getShortestName($fromSchema->getName());
         $table = $fromSchema->getTable($tableName);
         if (!$toSchema->hasTable($tableName)) {
             $diff->removedTables[$tableName] = $table;
         }
         // also remember all foreign keys that point to a specific table
         foreach ($table->getForeignKeys() as $foreignKey) {
             $foreignTable = strtolower($foreignKey->getForeignTableName());
             if (!isset($foreignKeysToTable[$foreignTable])) {
                 $foreignKeysToTable[$foreignTable] = array();
             }
             $foreignKeysToTable[$foreignTable][] = $foreignKey;
         }
     }
     foreach ($diff->removedTables as $tableName => $table) {
         if (isset($foreignKeysToTable[$tableName])) {
             $diff->orphanedForeignKeys = array_merge($diff->orphanedForeignKeys, $foreignKeysToTable[$tableName]);
             // deleting duplicated foreign keys present on both on the orphanedForeignKey
             // and the removedForeignKeys from changedTables
             foreach ($foreignKeysToTable[$tableName] as $foreignKey) {
                 // strtolower the table name to make if compatible with getShortestName
                 $localTableName = strtolower($foreignKey->getLocalTableName());
                 if (isset($diff->changedTables[$localTableName])) {
                     foreach ($diff->changedTables[$localTableName]->removedForeignKeys as $key => $removedForeignKey) {
                         # BUG-1481
                         if ($removedForeignKey->getLocalTableName() == $tableName) {
                             unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]);
                         }
                     }
                 }
             }
         }
     }
     foreach ($toSchema->getSequences() as $sequence) {
         $sequenceName = $sequence->getShortestName($toSchema->getName());
         if (!$fromSchema->hasSequence($sequenceName)) {
             if (!$this->isAutoIncrementSequenceInSchema($fromSchema, $sequence)) {
                 $diff->newSequences[] = $sequence;
             }
         } else {
             if ($this->diffSequence($sequence, $fromSchema->getSequence($sequenceName))) {
                 $diff->changedSequences[] = $toSchema->getSequence($sequenceName);
             }
         }
     }
     foreach ($fromSchema->getSequences() as $sequence) {
         if ($this->isAutoIncrementSequenceInSchema($toSchema, $sequence)) {
             continue;
         }
         $sequenceName = $sequence->getShortestName($fromSchema->getName());
         if (!$toSchema->hasSequence($sequenceName)) {
             $diff->removedSequences[] = $sequence;
         }
     }
     return $diff;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:96,代码来源:Comparator.php

示例7: getDiff

 /**
  * @param Schema $targetSchema
  * @param \Doctrine\DBAL\Connection $connection
  * @return \Doctrine\DBAL\Schema\SchemaDiff
  * @throws DBALException
  */
 protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
 {
     // adjust varchar columns with a length higher then getVarcharMaxLength to clob
     foreach ($targetSchema->getTables() as $table) {
         foreach ($table->getColumns() as $column) {
             if ($column->getType() instanceof StringType) {
                 if ($column->getLength() > $connection->getDatabasePlatform()->getVarcharMaxLength()) {
                     $column->setType(Type::getType('text'));
                     $column->setLength(null);
                 }
             }
         }
     }
     $filterExpression = $this->getFilterExpression();
     $this->connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
     $sourceSchema = $connection->getSchemaManager()->createSchema();
     // remove tables we don't know about
     /** @var $table \Doctrine\DBAL\Schema\Table */
     foreach ($sourceSchema->getTables() as $table) {
         if (!$targetSchema->hasTable($table->getName())) {
             $sourceSchema->dropTable($table->getName());
         }
     }
     // remove sequences we don't know about
     foreach ($sourceSchema->getSequences() as $table) {
         if (!$targetSchema->hasSequence($table->getName())) {
             $sourceSchema->dropSequence($table->getName());
         }
     }
     $comparator = new Comparator();
     return $comparator->compare($sourceSchema, $targetSchema);
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:38,代码来源:Migrator.php

示例8: getDiff

 protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
 {
     $sourceSchema = $connection->getSchemaManager()->createSchema();
     // remove tables we don't know about
     /** @var $table \Doctrine\DBAL\Schema\Table */
     foreach ($sourceSchema->getTables() as $table) {
         if (!$targetSchema->hasTable($table->getName())) {
             $sourceSchema->dropTable($table->getName());
         }
     }
     // remove sequences we don't know about
     foreach ($sourceSchema->getSequences() as $table) {
         if (!$targetSchema->hasSequence($table->getName())) {
             $sourceSchema->dropSequence($table->getName());
         }
     }
     $comparator = new Comparator();
     return $comparator->compare($sourceSchema, $targetSchema);
 }
开发者ID:Romua1d,项目名称:core,代码行数:19,代码来源:migrator.php

示例9: testDropSequence

 public function testDropSequence()
 {
     $sequence = new Sequence("a_seq", 1, 1);
     $schema = new Schema(array(), array($sequence));
     $schema->dropSequence("a_seq");
     $this->assertFalse($schema->hasSequence("a_seq"));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:7,代码来源:SchemaTest.php

示例10: getDiff

 protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
 {
     $connection->getConfiguration()->setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
     $sourceSchema = $connection->getSchemaManager()->createSchema();
     // remove tables we don't know about
     /** @var $table \Doctrine\DBAL\Schema\Table */
     foreach ($sourceSchema->getTables() as $table) {
         if (!$targetSchema->hasTable($table->getName())) {
             $sourceSchema->dropTable($table->getName());
         }
     }
     // remove sequences we don't know about
     foreach ($sourceSchema->getSequences() as $table) {
         if (!$targetSchema->hasSequence($table->getName())) {
             $sourceSchema->dropSequence($table->getName());
         }
     }
     $comparator = new Comparator();
     return $comparator->compare($sourceSchema, $targetSchema);
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:20,代码来源:migrator.php


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