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


PHP SchemaTool::dropSchema方法代码示例

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


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

示例1: createSchema

 public function createSchema($table)
 {
     foreach (self::$classes as $meta) {
         if ($table === $meta->getTableName() || ".{$table}" === substr($meta->getTableName(), -strlen(".{$table}"))) {
             self::$tool->dropSchema([$meta]);
             self::$tool->createSchema([$meta]);
         }
     }
 }
开发者ID:sinergi,项目名称:core,代码行数:9,代码来源:DatabaseTestCase.php

示例2: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $em = self::getEntityManager();
     $metaData = $em->getMetadataFactory()->getAllMetadata();
     self::$schemaTool = new SchemaTool($em);
     self::$schemaTool->dropSchema($metaData);
     self::$schemaTool->createSchema($metaData);
     static::prepareTestData($em);
 }
开发者ID:bedrest,项目名称:model-doctrine,代码行数:9,代码来源:FunctionalDoctrineTestCase.php

示例3: doSetUpBeforeClass

 /**
  * {@inheritdoc}
  */
 public static function doSetUpBeforeClass()
 {
     static::$schemaTool = new SchemaTool(static::$em);
     static::$schemaTool->dropSchema(static::getTablesMetadata());
     static::$schemaTool->createSchema(static::getTablesMetadata());
     static::$encoder = static::$container->get('security.encoder_factory');
     static::$user = new User();
     static::$user->setEmail('test@test.com');
     static::$user->setPassword(static::$encoder->getEncoder(static::$user)->encodePassword('1234', static::$user->getSalt()));
     static::$user->setUsername('testUser');
     $entityPermissionCategory = new PermissionCategory();
     $entityPermissionCategory->setName('backend_user');
     $entityPermissionCategory->setTechnicalName('backend_user');
     static::$em->persist($entityPermissionCategory);
     $entityPermission = new Permission();
     $entityPermission->setRoleName('IS_AUTHENTICATED_FULLY');
     $entityPermission->setDescription('IS_AUTHENTICATED_FULLY');
     $entityPermission->setName('IS_AUTHENTICATED_FULLY');
     $entityPermission->setCategory($entityPermissionCategory);
     $entityPermission2 = new Permission();
     $entityPermission2->setRoleName('ROLE_MANAGE_PERMISSIONS');
     $entityPermission2->setDescription('ROLE_MANAGE_PERMISSIONS');
     $entityPermission2->setName('ROLE_MANAGE_PERMISSIONS');
     $entityPermission2->setCategory($entityPermissionCategory);
     $entityPermission3 = new Permission();
     $entityPermission3->setRoleName('ROLE_ACCESS_BACKEND_TOOLS_SECURITY_SECTION');
     $entityPermission3->setDescription('ROLE_ACCESS_BACKEND_TOOLS_SECURITY_SECTION');
     $entityPermission3->setName('ROLE_ACCESS_BACKEND_TOOLS_SECURITY_SECTION');
     $entityPermission3->setCategory($entityPermissionCategory);
     $entityPermission4 = new Permission();
     $entityPermission4->setRoleName('ROLE_MANAGE_USER_PROFILES');
     $entityPermission4->setDescription('ROLE_MANAGE_USER_PROFILES');
     $entityPermission4->setName('ROLE_MANAGE_USER_PROFILES');
     $entityPermission4->setCategory($entityPermissionCategory);
     static::$em->persist($entityPermission);
     static::$em->persist($entityPermission2);
     static::$em->persist($entityPermission3);
     static::$em->persist($entityPermission4);
     static::$em->flush();
     $group = new Group();
     $group->setRefName('BACKEND-USER');
     $group->setName('backend-user');
     $group->addPermission($entityPermission);
     $group->addPermission($entityPermission2);
     $group->addPermission($entityPermission3);
     $group->addPermission($entityPermission4);
     static::$user->addToGroup($group);
     static::$em->persist($group);
     static::$em->persist(static::$user);
     static::$em->flush();
 }
开发者ID:modera,项目名称:foundation,代码行数:54,代码来源:UsersControllerTest.php

示例4: setUp

 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->client = $this->createClient(['debug' => false]);
     $container = static::$kernel->getContainer();
     /** @var EntityManagerInterface[] $managers */
     $managers = $container->get('doctrine')->getManagers();
     foreach ($managers as $manager) {
         $metadata = $manager->getMetadataFactory()->getAllMetadata();
         if (!empty($metadata)) {
             $tool = new SchemaTool($manager);
             $tool->dropSchema($metadata);
             $tool->createSchema($metadata);
         }
     }
     $class = $container->getParameter('tree_house.keystone.model.user.class');
     $salt = uniqid();
     /** @var UserInterface $user */
     $user = new $class();
     $user->setEnabled(true);
     $user->setUsername('test');
     $user->addRole('ROLE_USER');
     $user->setSalt($salt);
     /** @var EncoderFactoryInterface $encoder */
     $encoder = $container->get('security.encoder_factory');
     $password = $encoder->getEncoder($class)->encodePassword(static::$password, $user->getSalt());
     $user->setPassword($password);
     /** @var ManagerRegistry $doctrine */
     $doctrine = static::$kernel->getContainer()->get('doctrine');
     $manager = $doctrine->getManagerForClass($class);
     $manager->persist($user);
     $manager->flush($user);
     $manager->refresh($user);
     $this->user = $user;
 }
开发者ID:treehouselabs,项目名称:keystone-bundle,代码行数:38,代码来源:WebTestCase.php

示例5: clean

 public static function clean(EntityManager $entityManager)
 {
     $metadatas = $entityManager->getMetadataFactory()->getAllMetadata();
     $database = new SchemaTool($entityManager);
     $database->dropSchema($metadatas);
     $database->createSchema($metadatas);
 }
开发者ID:JavierCane,项目名称:mpwar,代码行数:7,代码来源:DatabaseCleaner.php

示例6: adminRefreshDatabaseAction

 public function adminRefreshDatabaseAction(Request $request, Application $app)
 {
     $conn = $app['db'];
     $em = $app['doctrine.orm.entity_manager'];
     $params = $conn->getParams();
     $name = isset($params['path']) ? $params['path'] : (isset($params['dbname']) ? $params['dbname'] : false);
     try {
         $conn->getSchemaManager()->dropDatabase($name);
         $conn->getSchemaManager()->createDatabase($name);
         $conn->close();
     } catch (\Exception $e) {
         return 1;
     }
     $classes = [];
     foreach ($app['authbucket_oauth2.model'] as $class) {
         $classes[] = $em->getClassMetadata($class);
     }
     PersistentObject::setObjectManager($em);
     $tool = new SchemaTool($em);
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
     $purger = new ORMPurger();
     $executor = new ORMExecutor($em, $purger);
     $loader = new Loader();
     $loader->loadFromDirectory(__DIR__ . '/../DataFixtures/ORM');
     $executor->execute($loader->getFixtures());
     return $app->redirect($app['url_generator']->generate('index'));
 }
开发者ID:miguelbemartin,项目名称:oauth2-php,代码行数:28,代码来源:DefaultController.php

示例7: createDatabaseSchema

 private function createDatabaseSchema(EntityManager $em)
 {
     $tool = new SchemaTool($em);
     $allMetadata = $em->getMetadataFactory()->getAllMetadata();
     $tool->dropSchema($allMetadata);
     $tool->createSchema($allMetadata);
 }
开发者ID:amstaffix,项目名称:generator-alice-fixtures-from-db,代码行数:7,代码来源:FixturesFromDBGeneratorTest.php

示例8: 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

示例9: setUp

 /**
  * Test setup
  */
 protected function setUp()
 {
     // setup entity aliases
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $entityManagerNamespaces = $this->em->getConfiguration()->getEntityNamespaces();
     $entityManagerNamespaces['WebtownPhpBannerBundle'] = 'WebtownPhp\\BannerBundle\\Entity';
     $this->em->getConfiguration()->setEntityNamespaces($entityManagerNamespaces);
     // setup schema
     $schemaTool = new SchemaTool($this->em);
     $classes = [];
     foreach ($this->getEntities() as $entityClass) {
         $classes[] = $this->em->getClassMetadata($entityClass);
     }
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     $registry = \Mockery::mock('Doctrine\\Bundle\\DoctrineBundle\\Registry');
     $registry->shouldReceive('getManager')->andReturn($this->em);
     $this->bm = new ORMManager($registry, new EventDispatcher());
 }
开发者ID:webtown-php,项目名称:BannerBundle,代码行数:28,代码来源:OMTestCase.php

示例10: setUp

 /**
  * Initializes the database (once).
  *
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\Tools\ToolsException
  */
 protected function setUp()
 {
     if (null === static::$_conn) {
         $dbPath = __DIR__ . '/../../../db.sqlite';
         if (file_exists($dbPath)) {
             unlink($dbPath);
         }
         $params = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
         static::$_conn = DriverManager::getConnection($params);
         static::$_conn->getConfiguration()->setSQLLogger(null);
     }
     if (null === static::$_em) {
         $paths = [__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/ORM/Resources/mapping'];
         $isDevMode = true;
         $config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
         $em = EntityManager::create(static::$_conn, $config);
         $classes = [];
         foreach (static::$_classes as $class) {
             array_push($classes, $em->getClassMetadata($class));
         }
         $schemaTool = new SchemaTool($em);
         $schemaTool->dropSchema($classes);
         $schemaTool->createSchema($classes);
         // Load fixtures
         $loader = new Loader();
         $loader->loadFromDirectory(__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/Fixtures');
         $purger = new ORMPurger();
         $executor = new ORMExecutor($em, $purger);
         $executor->execute($loader->getFixtures());
         static::$_em = $em;
     }
 }
开发者ID:ekyna,项目名称:commerce,代码行数:39,代码来源:DatabaseTestCase.php

示例11: testCreateSchema

 function testCreateSchema()
 {
     /* @var $em \Doctrine\ORM\EntityManager */
     $em = $this->app["orm.em"];
     $tool = new SchemaTool($em);
     //@note @doctrine générer les fichiers de classe à partir de métadonnées
     /* generate entity classes */
     $dmf = new DisconnectedClassMetadataFactory();
     $dmf->setEntityManager($em);
     $metadatas = $dmf->getAllMetadata();
     //print_r($metadatas);
     $generator = new EntityGenerator();
     $generator->setGenerateAnnotations(TRUE);
     $generator->setGenerateStubMethods(TRUE);
     $generator->setRegenerateEntityIfExists(TRUE);
     $generator->setUpdateEntityIfExists(TRUE);
     $generator->generate($metadatas, ROOT_TEST_DIR);
     $generator->setNumSpaces(4);
     $this->assertFileExists(ROOT_TEST_DIR . "/Entity/Post.php");
     /* @note @doctrine générer la base de donnée à partir des métadonnées */
     /* @see Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand */
     /* generate database */
     $tool->dropSchema($metadatas);
     $tool->createSchema($metadatas);
     $post = new \Entity\Post();
     $post->setTitle("the title");
     $em->persist($post);
     $em->flush();
     $this->assertInternalType("int", $post->getId());
 }
开发者ID:mparaiso,项目名称:doctrineormserviceprovider,代码行数:30,代码来源:DoctrineOrmServiceProviderTest.php

示例12: initOrm

 protected function initOrm(EntityManagerInterface $entityManager)
 {
     $schemaTool = new SchemaTool($entityManager);
     $metadatas = $entityManager->getMetadataFactory()->getAllMetadata();
     $schemaTool->dropSchema($metadatas);
     $schemaTool->createSchema($metadatas);
 }
开发者ID:symfony-cmf,项目名称:content-type,代码行数:7,代码来源:OrmTestCase.php

示例13: 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

示例14: setUp

 protected function setUp()
 {
     if (!class_exists('Symfony\\Component\\Form\\Form')) {
         $this->markTestSkipped('The "Form" component is not available');
     }
     if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
         $this->markTestSkipped('Doctrine DBAL is not available.');
     }
     if (!class_exists('Doctrine\\Common\\Version')) {
         $this->markTestSkipped('Doctrine Common is not available.');
     }
     if (!class_exists('Doctrine\\ORM\\EntityManager')) {
         $this->markTestSkipped('Doctrine ORM is not available.');
     }
     $this->em = DoctrineOrmTestCase::createTestEntityManager();
     $this->emRegistry = $this->createRegistryMock('default', $this->em);
     parent::setUp();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::ITEM_GROUP_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_STRING_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_STRING_IDENT_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:28,代码来源:EntityTypeTest.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     if (!class_exists('Symfony\\Component\\Form\\Form')) {
         $this->markTestSkipped('The "Form" component is not available');
     }
     if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
         $this->markTestSkipped('Doctrine DBAL is not available.');
     }
     if (!class_exists('Doctrine\\Common\\Version')) {
         $this->markTestSkipped('Doctrine Common is not available.');
     }
     if (!class_exists('Doctrine\\ORM\\EntityManager')) {
         $this->markTestSkipped('Doctrine ORM is not available.');
     }
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $this->emRegistry = $this->createRegistryMock('default', $this->em);
     $this->items = array();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::SINGLE_INT_ID_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     $this->createEntities();
     $this->factory = Forms::createFormFactoryBuilder()->addExtensions($this->getExtensions())->addTypeExtension(new ChoiceSelect2TypeExtension($this->dispatcher, $this->requestStack, $this->router, $this->getExtensionTypeName(), 10))->addType(new EntityType($this->emRegistry))->addTypeExtension(new EntitySelect2TypeExtension())->getFormFactory();
     $this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
 }
开发者ID:mcdir,项目名称:SonatraFormExtensionsBundle,代码行数:32,代码来源:EntitySelect2TypeExtensionTest.php


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