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


PHP SchemaTool::getDropSchemaSQL方法代码示例

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


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

示例1: executeSchemaCommand

 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     $isFullDatabaseDrop = $input->getOption('full-database');
     if ($input->getOption('dump-sql') === true) {
         if ($isFullDatabaseDrop) {
             $sqls = $schemaTool->getDropDatabaseSQL();
         } else {
             $sqls = $schemaTool->getDropSchemaSQL($metadatas);
         }
         $output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL);
     } else {
         if ($input->getOption('force') === true) {
             $output->write('Dropping database schema...' . PHP_EOL);
             if ($isFullDatabaseDrop) {
                 $schemaTool->dropDatabase();
             } else {
                 $schemaTool->dropSchema($metadatas);
             }
             $output->write('Database schema dropped successfully!' . PHP_EOL);
         } else {
             $output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL . PHP_EOL);
             if ($isFullDatabaseDrop) {
                 $sqls = $schemaTool->getDropDatabaseSQL();
             } else {
                 $sqls = $schemaTool->getDropSchemaSQL($metadatas);
             }
             if (count($sqls)) {
                 $output->write('Schema-Tool would execute ' . count($sqls) . ' queries to drop the database.' . PHP_EOL);
                 $output->write('Please run the operation with --force to execute these queries or use --dump-sql to see them.' . PHP_EOL);
             } else {
                 $output->write('Nothing to drop. The database is empty!' . PHP_EOL);
             }
         }
     }
 }
开发者ID:krishcdbry,项目名称:z-zangura,代码行数:35,代码来源:DropCommand.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $sql = $this->tool->getDropSchemaSQL($this->metadata->getAllMetadata());
     if (empty($sql)) {
         $this->info('Current models do not exist in schema.');
         return;
     }
     if ($this->option('sql')) {
         $this->info('Outputting drop query:');
         $this->info(implode(';' . PHP_EOL, $sql));
     } else {
         $this->info('Dropping database schema....');
         $this->tool->dropSchema($this->metadata->getAllMetadata());
         $this->info('Schema has been dropped!');
     }
 }
开发者ID:jonesio,项目名称:laravel-doctrine,代码行数:21,代码来源:SchemaDropCommand.php

示例3: testDropTable

 /**
  * There seems to be a bug when I try to drop a table.
  */
 public function testDropTable()
 {
     $statements = $this->tool->getDropSchemaSQL($this->classes);
     $this->assertInternalType('array', $statements);
     $this->assertSame('DROP SEQUENCE test_id_seq CASCADE', $statements[0]);
     $this->assertSame('DROP TABLE test', $statements[1]);
 }
开发者ID:epoplive,项目名称:EasyBib_DoctrineTypes,代码行数:10,代码来源:HstoreTestCase.php

示例4: uninstallEntity

 public function uninstallEntity(array $entity)
 {
     $metadata = $this->getMetadata($entity);
     $tool = new SchemaTool($this->_em);
     $queries = $tool->getDropSchemaSQL($metadata);
     return $this->persist($queries ?: array());
 }
开发者ID:controleonline,项目名称:core,代码行数:7,代码来源:InstallModel.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $this->error('ATTENTION: This operation should not be executed in a production environment.');
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $tool = new SchemaTool($em);
         $this->info('');
         $this->message('Checking scheme for <info>' . $name . '</info> entity manager...');
         if ($this->option('sql')) {
             if ($this->option('full')) {
                 $sql = $tool->getDropDatabaseSQL();
             } else {
                 $sql = $tool->getDropSchemaSQL($em->getMetadataFactory()->getAllMetadata());
             }
             $this->comment('     ' . implode(';     ' . PHP_EOL, $sql));
         } else {
             if ($this->option('force')) {
                 $this->message('Dropping database schema...');
                 if ($this->option('full')) {
                     $tool->dropDatabase();
                 } else {
                     $tool->dropSchema($em->getMetadataFactory()->getAllMetadata());
                 }
                 $this->info('Database schema dropped successfully!');
             }
             if ($this->option('full')) {
                 $sql = $tool->getDropDatabaseSQL();
             } else {
                 $sql = $tool->getDropSchemaSQL($em->getMetadataFactory()->getAllMetadata());
             }
             if (count($sql)) {
                 $pluralization = 1 === count($sql) ? 'query was' : 'queries were';
                 $this->message(sprintf('The Schema-Tool would execute <info>"%s"</info> %s to update the database.', count($sql), $pluralization));
                 $this->message('Please run the operation by passing one - or both - of the following options:');
                 $this->comment(sprintf('    <info>php artisan %s --force</info> to execute the command', $this->getName()));
                 $this->comment(sprintf('    <info>php artisan %s --sql</info> to dump the SQL statements to the screen', $this->getName()));
             } else {
                 $this->error('Nothing to drop. The database is empty!');
             }
         }
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:48,代码来源:SchemaDropCommand.php

示例6: fire

 public function fire()
 {
     $sql = $this->tool->getDropSchemaSQL($this->metadata->getAllMetadata());
     if (empty($sql)) {
         $this->error('Current models do not exist in schema.');
         return;
     }
     if ($this->option('sql')) {
         $this->info('Outputting drop query:' . PHP_EOL);
         $this->line(implode(';' . PHP_EOL, $sql) . ';');
     } else {
         if ($this->option('commit')) {
             $this->info('Dropping database schema....');
             $this->tool->dropSchema($this->metadata->getAllMetadata());
             $this->info('Schema has been dropped!');
         } else {
             $this->comment("Warning: this command can cause data loss. Run with --sql or --commit.");
         }
     }
 }
开发者ID:jeanbelhache,项目名称:doctrine2-l5,代码行数:20,代码来源:Drop.php

示例7: executeSchemaCommand

 /**
  * {@inheritdoc}
  */
 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     $isFullDatabaseDrop = $input->getOption('full-database');
     if ($input->getOption('dump-sql')) {
         if ($isFullDatabaseDrop) {
             $sqls = $schemaTool->getDropDatabaseSQL();
         } else {
             $sqls = $schemaTool->getDropSchemaSQL($metadatas);
         }
         $output->writeln(implode(';' . PHP_EOL, $sqls));
         return 0;
     }
     if ($input->getOption('force')) {
         $output->writeln('Dropping database schema...');
         if ($isFullDatabaseDrop) {
             $schemaTool->dropDatabase();
         } else {
             $schemaTool->dropSchema($metadatas);
         }
         $output->writeln('Database schema dropped successfully!');
         return 0;
     }
     $output->writeln('<comment>ATTENTION</comment>: This operation should not be executed in a production environment.' . PHP_EOL);
     if ($isFullDatabaseDrop) {
         $sqls = $schemaTool->getDropDatabaseSQL();
     } else {
         $sqls = $schemaTool->getDropSchemaSQL($metadatas);
     }
     if (count($sqls)) {
         $output->writeln(sprintf('The Schema-Tool would execute <info>"%s"</info> queries to update the database.', count($sqls)));
         $output->writeln('Please run the operation by passing one - or both - of the following options:');
         $output->writeln(sprintf('    <info>%s --force</info> to execute the command', $this->getName()));
         $output->writeln(sprintf('    <info>%s --dump-sql</info> to dump the SQL statements to the screen', $this->getName()));
         return 1;
     }
     $output->writeln('Nothing to drop. The database is empty!');
     return 0;
 }
开发者ID:John-Eddy,项目名称:ProjetCastor,代码行数:41,代码来源:DropCommand.php

示例8: testGetDropSchemaSql

 public function testGetDropSchemaSql()
 {
     $classes = array($this->_em->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsAddress'), $this->_em->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser'), $this->_em->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsPhonenumber'));
     $tool = new SchemaTool($this->_em);
     $sql = $tool->getDropSchemaSQL($classes);
     $this->assertEquals(13, count($sql));
     $dropSequenceSQLs = 0;
     foreach ($sql as $stmt) {
         if (strpos($stmt, "DROP SEQUENCE") === 0) {
             $dropSequenceSQLs++;
         }
     }
     $this->assertEquals(4, $dropSequenceSQLs, "Expect 4 sequences to be dropped.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:14,代码来源:PostgreSqlSchemaToolTest.php

示例9: dropPluginSchema

 /**
  * Drops plugin's tables based on Doctrine metadata.
  *
  * @param array         $metadata
  * @param MauticFactory $factory
  *
  * @throws \Doctrine\DBAL\ConnectionException
  * @throws \Exception
  */
 public static function dropPluginSchema(array $metadata, MauticFactory $factory)
 {
     $db = $factory->getDatabase();
     $schemaTool = new SchemaTool($factory->getEntityManager());
     $dropQueries = $schemaTool->getDropSchemaSQL($metadata);
     $db->beginTransaction();
     try {
         foreach ($dropQueries as $q) {
             $db->query($q);
         }
         $db->commit();
     } catch (\Exception $e) {
         $db->rollback();
         throw $e;
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:25,代码来源:PluginBundleBase.php


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