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


PHP SchemaTool::updateSchema方法代码示例

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


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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     if (!GeometryEngineRegistry::has()) {
         $this->markTestSkipped('This test requires a connection to a database.');
     }
     $engine = GeometryEngineRegistry::get();
     if (!$engine instanceof PDOEngine) {
         $this->markTestSkipped('This test currently only works with a PDO connection.');
     }
     $this->platform = $this->_conn->getDatabasePlatform();
     $this->platform->registerDoctrineTypeMapping('geometry', 'binary');
     $this->platform->registerDoctrineTypeMapping('linestring', 'binary');
     $this->platform->registerDoctrineTypeMapping('multilinestring', 'binary');
     $this->platform->registerDoctrineTypeMapping('multipoint', 'binary');
     $this->platform->registerDoctrineTypeMapping('multipolygon', 'binary');
     $this->platform->registerDoctrineTypeMapping('point', 'binary');
     $this->platform->registerDoctrineTypeMapping('polygon', 'binary');
     switch ($this->platform->getName()) {
         case 'postgresql':
             $this->_conn->executeQuery('CREATE EXTENSION IF NOT EXISTS postgis;');
             break;
     }
     $this->fixtureLoader = new Loader();
     $config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/Fixtures'], false);
     $config->addCustomNumericFunction('EarthDistance', EarthDistanceFunction::class);
     $this->em = EntityManager::create($this->_conn, $config, $this->platform->getEventManager());
     $this->schemaTool = new SchemaTool($this->em);
     $this->schemaTool->updateSchema([$this->em->getClassMetadata(Fixtures\GeometryEntity::class), $this->em->getClassMetadata(Fixtures\LineStringEntity::class), $this->em->getClassMetadata(Fixtures\MultiLineStringEntity::class), $this->em->getClassMetadata(Fixtures\MultiPointEntity::class), $this->em->getClassMetadata(Fixtures\MultiPolygonEntity::class), $this->em->getClassMetadata(Fixtures\PointEntity::class), $this->em->getClassMetadata(Fixtures\PolygonEntity::class)]);
     $purger = new ORMPurger();
     $this->ormExecutor = new ORMExecutor($this->em, $purger);
 }
开发者ID:brick,项目名称:geo,代码行数:35,代码来源:FunctionalTestCase.php

示例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);
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:13,代码来源:Populator.php

示例3: setUp

 /**
  * Set up test env
  *
  * @return void
  */
 public function setUp()
 {
     $this->eventDispatcher = new EventDispatcher();
     $this->params = new CollectorParamBag();
     $setup = Setup::createAnnotationMetadataConfiguration([ENTITIES], true);
     $this->em = EntityManager::create(['driver' => 'pdo_mysql', 'user' => 'user', 'password' => '', 'dbname' => 'warden'], $setup);
     // Setup Param Bag
     $this->params->add('query_limit', ['type' => 'integer', 'default' => 5, 'limit' => 5, 'value' => null, 'expression' => 'value >= limit']);
     // Sync the schema
     $this->schema = new SchemaTool($this->em);
     $this->schema->updateSchema($this->em->getMetadataFactory()->getAllMetadata(), true);
     // Events
     $this->start = new StartEvent();
     $this->stop = new StopEvent($this->params);
 }
开发者ID:Bluetel-Solutions,项目名称:Warden,代码行数:20,代码来源:DoctrineCollectorTest.php

示例4: update_entity_settings

 public function update_entity_settings()
 {
     if (!$this->token->validate("update_entity_settings")) {
         $this->error->add($this->token->getErrorMessage());
     }
     if (!$this->error->has()) {
         if ($this->isPost()) {
             $ddm = $this->post('DOCTRINE_DEV_MODE') == 1 ? 1 : 0;
             if ($this->request->request->get('refresh')) {
                 $em = ORM::entityManager();
                 $config = $em->getConfiguration();
                 // First, we flush the metadata cache.
                 if (is_object($cache = $config->getMetadataCacheImpl())) {
                     $cache->flushAll();
                 }
                 // Next, we regnerate proxies
                 $metadatas = $em->getMetadataFactory()->getAllMetadata();
                 $em->getProxyFactory()->generateProxyClasses($metadatas, $this->app->make('config')->get('database.proxy_classes'));
                 // Finally, we update the schema
                 $tool = new SchemaTool($em);
                 $tool->updateSchema($metadatas, true);
                 $this->flash('success', t('Doctrine cache cleared, proxy classes regenerated, entity database table schema updated.'));
                 $this->redirect('/dashboard/system/environment/entities', 'view');
             } else {
                 Config::save('concrete.cache.doctrine_dev_mode', (bool) $ddm);
                 $this->flash('success', t('Doctrine development settings updated.'));
             }
             $this->redirect('/dashboard/system/environment/entities', 'view');
         }
     } else {
         $this->set('error', array($this->token->getErrorMessage()));
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:33,代码来源:entities.php

示例5: execute

 /**
  * Runs command
  *
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln($this->getDescription());
     /** @var EntityManager $em */
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     /** @var ConfigManager $configManager */
     $configManager = $this->getContainer()->get('oro_entity_config.config_manager');
     $metadata = array_filter($em->getMetadataFactory()->getAllMetadata(), function ($doctrineMetadata) use($configManager) {
         /** @var ClassMetadataInfo $doctrineMetadata */
         return $this->isExtendEntity($doctrineMetadata->getReflectionClass()->getName(), $configManager);
     });
     $schemaTool = new SchemaTool($em);
     $sqls = $schemaTool->getUpdateSchemaSql($metadata, true);
     if (0 === count($sqls)) {
         $output->writeln('Nothing to update - a database is already in sync with the current entity metadata.');
     } else {
         if ($input->getOption('dry-run')) {
             $output->writeln(implode(';' . PHP_EOL, $sqls) . ';');
         } else {
             $output->writeln('Updating database schema...');
             $schemaTool->updateSchema($metadata, true);
             $output->writeln(sprintf('Database schema updated successfully! "<info>%s</info>" queries were executed', count($sqls)));
         }
     }
     if (!$input->getOption('dry-run')) {
         /** @var EnumSynchronizer $enumSynchronizer */
         $enumSynchronizer = $this->getContainer()->get('oro_entity_extend.enum_synchronizer');
         $enumSynchronizer->sync();
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:37,代码来源:UpdateSchemaCommand.php

示例6: executeSchemaCommand

 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     // Defining if update is complete or not (--complete not defined means $saveMode = true)
     $saveMode = $input->getOption('complete') !== true;
     $sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode);
     if (0 == count($sqls)) {
         $output->writeln('Nothing to update - your database is already in sync with the current entity metadata.');
         return;
     }
     $dumpSql = true === $input->getOption('dump-sql');
     $force = true === $input->getOption('force');
     if ($dumpSql && $force) {
         throw new \InvalidArgumentException('You can pass either the --dump-sql or the --force option (but not both simultaneously).');
     }
     if ($dumpSql) {
         $output->writeln(implode(';' . PHP_EOL, $sqls));
     } else {
         if ($force) {
             $output->writeln('Updating database schema...');
             $schemaTool->updateSchema($metadatas, $saveMode);
             $output->writeln(sprintf('Database schema updated successfully! "<info>%s</info>" queries were executed', count($sqls)));
         } else {
             $output->writeln('<comment>ATTENTION</comment>: This operation should not be executed in a production environment.');
             $output->writeln('           Use the incremental update to detect changes during development and use');
             $output->writeln('           the SQL DDL provided to manually update your database in production.');
             $output->writeln('');
             $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 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()));
         }
     }
 }
开发者ID:laiello,项目名称:masfletes,代码行数:33,代码来源:UpdateCommand.php

示例7: main

 /**
  * main method
  *
  * @return void
  */
 public function main()
 {
     static $em;
     if ($em === null) {
         $wd = getcwd();
         $zf = $this->project->getProperty('zf');
         $application = (require $zf);
         if (!$application instanceof Application) {
             throw new BuildException(sprintf('zf bootstrap file "%s" should return an instance of Zend\\Mvc\\Application', $zf));
         }
         chdir($wd);
         $em = $application->getServiceManager()->get($this->em);
     }
     $metadatas = $em->getMetadataFactory()->getAllMetadata();
     if (!empty($metadatas)) {
         $tool = new SchemaTool($em);
         $sqls = $tool->getUpdateSchemaSql($metadatas, false);
         if (0 === count($sqls)) {
             $this->log('Nothing to update - your database is already in sync with the current entity metadata.');
         } else {
             $this->log('Updating database schema...');
             $tool->updateSchema($metadatas, false);
             $this->log(sprintf('Database schema updated successfully! %s queries were executed', count($sqls)));
         }
     } else {
         $this->log('No metadata classes to process');
     }
 }
开发者ID:heartsentwined,项目名称:zf2-phing-task,代码行数:33,代码来源:DoctrineUpdateTask.php

示例8: handleDatabaseUpdate

 public function handleDatabaseUpdate(Args $args, IO $io, Command $command)
 {
     $tool = new SchemaTool($this->app['entyMgr']);
     $tool->updateSchema($this->app['entyMgr']->getMetadataFactory()->getAllMetadata());
     $io->writeLine("<info>Database schema updated.</info>");
     return 0;
 }
开发者ID:eric-chau,项目名称:doctrine-skill,代码行数:7,代码来源:DoctrineCommandHandler.php

示例9: rebuildSchema

 public function rebuildSchema()
 {
     $metadatas = $this->em->getMetadataFactory()->getAllMetadata();
     $tool = new SchemaTool($this->em);
     $tool->dropSchema($metadatas);
     $tool->updateSchema($metadatas, false);
 }
开发者ID:vinodpanicker,项目名称:behat,代码行数:7,代码来源:SchemaManager.php

示例10: execute

 public function execute()
 {
     $d = $this->factory()->appDoctrine();
     $this->app->dataStorage->clearStorage('CyantreeDoctrineModule/Proxies');
     $this->app->cacheStorage->clearStorage('CyantreeDoctrineModule');
     $tool = new SchemaTool($d);
     $queries = $tool->getUpdateSchemaSql($d->getMetadataFactory()->getAllMetadata());
     if ($queries) {
         $hash = '';
         foreach ($queries as $query) {
             $hash = md5($hash . $query);
         }
         $code = substr($hash, 0, 8);
         if ($transferredCode = $this->request->args->get('code')) {
             if ($transferredCode == $code) {
                 $tool->updateSchema($d->getMetadataFactory()->getAllMetadata());
                 $this->result->showSuccess('Schema has been updated.');
                 return;
             } else {
                 $this->result->showError('Passed invalid code.');
             }
         }
         $this->result->showWarning('Schema is not up to date. The following queries would be executed:');
         foreach ($queries as $query) {
             $this->result->showInfo($query);
         }
         $this->result->showWarning("Execute with -code={$code} to update the database schema.");
     } else {
         $this->result->showSuccess('Schema is up to date.');
     }
 }
开发者ID:cyantree,项目名称:grout-project,代码行数:31,代码来源:UpdateDatabaseSchemaCommand.php

示例11: executeSchemaCommand

 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     // Defining if update is complete or not (--complete not defined means $saveMode = true)
     $saveMode = $input->getOption('complete') !== true;
     if ($input->getOption('dump-sql') === true) {
         $sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode);
         $output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL);
     } else {
         if ($input->getOption('force') === true) {
             $output->write('Updating database schema...' . PHP_EOL);
             $schemaTool->updateSchema($metadatas, $saveMode);
             $output->write('Database schema updated successfully!' . PHP_EOL);
         } else {
             $output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL);
             $output->write('Use the incremental update to detect changes during development and use' . PHP_EOL);
             $output->write('this SQL DDL to manually update your database in production.' . PHP_EOL . PHP_EOL);
             $sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode);
             if (count($sqls)) {
                 $output->write('Schema-Tool would execute ' . count($sqls) . ' queries to update 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 update. The database is in sync with the current entity metadata.' . PHP_EOL);
             }
         }
     }
 }
开发者ID:halljb57,项目名称:flextrine,代码行数:26,代码来源:UpdateCommand.php

示例12: updateSchema

 public static function updateSchema($appName, $modelNames = null)
 {
     $em = self::getEntityManager($appName, $modelNames);
     $tool = new SchemaTool($em);
     $classes = self::getMetadata($appName, $modelNames);
     $tool->updateSchema($classes, true);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:7,代码来源:SchemaTool.php

示例13: schemaUpdateAction

 public function schemaUpdateAction()
 {
     /* @var $em EntityManager */
     $em = $this->serviceLocator->get("doctrine.entitymanager.orm_dest");
     $metadata = $em->getMetadataFactory()->getAllMetadata();
     $shemaTool = new SchemaTool($em);
     $shemaTool->updateSchema($metadata, true);
 }
开发者ID:ifigenija,项目名称:server,代码行数:8,代码来源:CrpalkaController.php

示例14: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->info('Checking if database needs updating....');
     $clean = $this->option('clean');
     $sql = $this->tool->getUpdateSchemaSql($this->metadata->getAllMetadata(), !$clean);
     if (empty($sql)) {
         $this->info('No updates found.');
         return;
     }
     if ($this->option('sql')) {
         $this->info('Outputting update query:');
         $this->info(implode(';' . PHP_EOL, $sql));
     } else {
         $this->info('Updating database schema....');
         $this->tool->updateSchema($this->metadata->getAllMetadata(), !$clean);
         $this->info('Schema has been updated!');
     }
 }
开发者ID:rsamborski,项目名称:laravel-doctrine,代码行数:23,代码来源:SchemaUpdateCommand.php

示例15: performDatabaseUpgrade

 protected function performDatabaseUpgrade()
 {
     /**
      * @var EntityManager
      */
     $entityManager = $this->container->get('doctrine')->getManager();
     $tool = new SchemaTool($entityManager);
     $meta = $this->container->get('doctrine')->getManager()->getMetadataFactory()->getAllMetadata();
     $tool->updateSchema($meta, true);
 }
开发者ID:partkeepr,项目名称:PartKeepr,代码行数:10,代码来源:BaseMigration.php


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