当前位置: 首页>>代码示例>>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方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeSchemaCommand

 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     if ($input->getOption('dump-sql') === true) {
         $sqls = $schemaTool->getDropSchemaSql($metadatas);
         $output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL);
     } else {
         $output->write('Dropping database schema...' . PHP_EOL);
         $schemaTool->dropSchema($metadatas);
         $output->write('Database schema dropped successfully!' . PHP_EOL);
     }
 }
开发者ID:nad2000,项目名称:doctrine2,代码行数:11,代码来源:DropCommand.php

示例2: executeSchemaCommand

 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     if ($input->getOption('dump-sql') === true) {
         $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);
             $schemaTool->dropSchema($metadatas);
             $output->write('Database schema dropped successfully!' . PHP_EOL);
         } 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:skoop,项目名称:symfony-sandbox,代码行数:21,代码来源:DropCommand.php

示例3: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $arguments = $this->getArguments();
     $printer = $this->getPrinter();
     $isCreate = isset($arguments['create']) && $arguments['create'];
     $isDrop = isset($arguments['drop']) && $arguments['drop'];
     $isUpdate = isset($arguments['update']) && $arguments['update'];
     $isCompleteUpdate = isset($arguments['complete-update']) && $arguments['complete-update'];
     $em = $this->getConfiguration()->getAttribute('em');
     $cmf = $em->getMetadataFactory();
     $classes = $cmf->getAllMetadata();
     if (empty($classes)) {
         $printer->writeln('No classes to process.', 'INFO');
         return;
     }
     $tool = new SchemaTool($em);
     if ($isDrop) {
         if (isset($arguments['dump-sql'])) {
             foreach ($tool->getDropSchemaSql($classes) as $sql) {
                 $printer->writeln($sql . ";");
             }
         } else {
             $printer->writeln('Dropping database schema...', 'INFO');
             $tool->dropSchema($classes);
             $printer->writeln('Database schema dropped successfully.', 'INFO');
         }
     }
     if ($isCreate) {
         if (isset($arguments['dump-sql'])) {
             foreach ($tool->getCreateSchemaSql($classes) as $sql) {
                 $printer->writeln($sql . ";");
             }
         } else {
             $printer->writeln('Creating database schema...', 'INFO');
             $tool->createSchema($classes);
             $printer->writeln('Database schema created successfully.', 'INFO');
         }
     }
     if ($isUpdate || $isCompleteUpdate) {
         $saveMode = $isUpdate ? true : false;
         if (isset($arguments['dump-sql'])) {
             foreach ($tool->getUpdateSchemaSql($classes, $saveMode) as $sql) {
                 $printer->writeln($sql . ";");
             }
         } else {
             $printer->writeln('Updating database schema...', 'INFO');
             $tool->updateSchema($classes, $saveMode);
             $printer->writeln('Database schema updated successfully.', 'INFO');
         }
     }
 }
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:54,代码来源:SchemaToolTask.php


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