本文整理汇总了PHP中Doctrine\ORM\Tools\SchemaTool::dropDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP SchemaTool::dropDatabase方法的具体用法?PHP SchemaTool::dropDatabase怎么用?PHP SchemaTool::dropDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Tools\SchemaTool
的用法示例。
在下文中一共展示了SchemaTool::dropDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
protected function tearDown()
{
// Clean anything still idle in the UOW
$this->_em->clear();
// Clear out anything set in the db (schema is recreated on setUp()
$this->_schemaTool->dropDatabase();
}
示例2: rebuildDatabase
/**
* Builds the DB Schema
*
* @return void
*/
protected function rebuildDatabase()
{
# 2. Drop the existing database schema
$this->schemaTool->dropDatabase();
# 3. Create the new database schema based on (1)
$entityMeta = $this->em->getMetadataFactory()->getAllMetadata();
$this->schemaTool->updateSchema($entityMeta);
}
示例3: tearDown
protected function tearDown()
{
parent::tearDown();
$tool = new SchemaTool($this->em);
$tool->dropDatabase();
unset($this->em);
}
示例4: 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);
}
}
}
}
示例5: loadFixtures
protected function loadFixtures($client)
{
$container = $this->getContainer($client);
$registry = $container->get('doctrine');
if ($registry instanceof ManagerRegistry) {
$om = $registry->getManager();
} else {
$om = $registry->getEntityManager();
}
$cacheDriver = $om->getMetadataFactory()->getCacheDriver();
if ($cacheDriver) {
$cacheDriver->deleteAll();
}
$connection = $om->getConnection();
$params = $connection->getParams();
$name = isset($params['path']) ? $params['path'] : (isset($params['dbname']) ? $params['dbname'] : false);
if (!$name) {
throw new \InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
}
$metadatas = $om->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($om);
$schemaTool->dropDatabase($name);
if (!empty($metadatas)) {
$schemaTool->createSchema($metadatas);
}
}
示例6: dropSchema
/**
* {@inheritDoc}
*/
public function dropSchema()
{
$this->foreachObjectManagers(function (ObjectManager $objectManager) {
$schemaTool = new DoctrineSchemaTool($objectManager);
$schemaTool->dropDatabase();
});
}
示例7: createSchemaTool
/**
* @param EntityManager $em
* @return SchemaTool
*/
private function createSchemaTool(EntityManager $em)
{
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase();
$schemaTool->createSchema($em->getMetadataFactory()->getAllMetadata());
return $schemaTool;
}
示例8: preTestSetUp
public function preTestSetUp(EntityManagerEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
$classes = array($em->getClassMetadata(__NAMESPACE__ . '\\Date'));
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase();
$schemaTool->createSchema($classes);
}
示例9: testSchemaDown
public function testSchemaDown()
{
$schemaTool = new SchemaTool($this->entityManager);
$schemaTool->dropDatabase();
$schemaManager = $this->entityManager->getConnection()->getSchemaManager();
$tables = $schemaManager->listTableNames();
$this->assertEmpty($tables);
}
示例10: setUp
public function setUp()
{
parent::setUp();
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase();
$schemaTool->createSchema($em->getMetadataFactory()->getAllMetadata());
}
开发者ID:bitecodes,项目名称:rest-api-generator-bundle,代码行数:8,代码来源:RestApiControllerWithSubResourcesTest.php
示例11: dropDatabases
/**
* Drops all databases
*
* @return void
*/
public function dropDatabases()
{
/** @var EntityManagerInterface[] $managers */
$managers = $this->get('doctrine')->getManagers();
foreach ($managers as $manager) {
$tool = new SchemaTool($manager);
$tool->dropDatabase();
}
}
示例12: preTestSetUp
public function preTestSetUp(EntityManagerEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
$schemaTool = new SchemaTool($em);
$cmf = $em->getMetadataFactory();
$classes = $cmf->getAllMetadata();
$schemaTool->dropDatabase();
$schemaTool->createSchema($classes);
}
示例13: initializeInMemoryDB
protected function initializeInMemoryDB()
{
$entityManager = $this->getEntityManager();
// try a real schema creation with the in memory sqlite driver
$classes = $entityManager->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($entityManager);
$schemaTool->dropDatabase();
$schemaTool->createSchema($classes);
}
示例14: setUp
public function setUp()
{
self::$kernel = $this->createKernel(array('environment' => 'test'));
self::$kernel->boot();
$this->container = self::$kernel->getContainer();
$em = $this->container->get('doctrine')->getEntityManager();
$metadatas = $em->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase();
$schemaTool->createSchema($metadatas);
}
示例15: setupDatabase
private function setupDatabase()
{
$params = SqliteConfig::getParams();
$entityManager = EntityManagerFactory::create($params);
$tmpConnection = DriverManager::getConnection($params);
$tmpConnection->getSchemaManager()->createDatabase($params['path']);
$schemaTool = new SchemaTool($entityManager);
$schemaTool->dropDatabase();
$metadata = $entityManager->getMetadataFactory()->getAllMetadata();
$schemaTool->createSchema($metadata);
}