本文整理汇总了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);
}
}
示例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);
}
}
}
}
示例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');
}
}
}