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


PHP SchemaTool::getCreateSchemaSql方法代码示例

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


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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if ($this->option('sql')) {
         $this->info('Outputting create query:');
         $sql = $this->tool->getCreateSchemaSql($this->metadata->getAllMetadata());
         $this->info(implode(';' . PHP_EOL, $sql));
     } else {
         $this->info('Creating database schema...');
         $this->tool->createSchema($this->metadata->getAllMetadata());
         $this->info('Schema has been created!');
     }
 }
开发者ID:jonesio,项目名称:laravel-doctrine,代码行数:17,代码来源:SchemaCreateCommand.php

示例2: updateEntity

 public function updateEntity(array $entity)
 {
     $metadata = $this->getMetadata($entity);
     $tool = new SchemaTool($this->_em);
     $queries = $tool->getCreateSchemaSql($metadata);
     return $this->persist($queries ?: array());
 }
开发者ID:controleonline,项目名称:core,代码行数:7,代码来源:InstallModel.php

示例3: testGetCreateSchemaSql4

 /**
  * @group DBAL-204
  */
 public function testGetCreateSchemaSql4()
 {
     $classes = array($this->_em->getClassMetadata(__NAMESPACE__ . '\\MysqlSchemaNamespacedEntity'));
     $tool = new SchemaTool($this->_em);
     $sql = $tool->getCreateSchemaSql($classes);
     $this->assertEquals(0, count($sql));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:10,代码来源:MySqlSchemaToolTest.php

示例4: fire

 public function fire()
 {
     if ($this->option('sql')) {
         $this->info('Outputting create query:' . PHP_EOL);
         $sql = $this->tool->getCreateSchemaSql($this->metadata->getAllMetadata());
         $this->info(implode(';' . PHP_EOL, $sql) . ';');
     } else {
         if ($this->option('commit')) {
             $this->info('Creating database schema...');
             $this->tool->createSchema($this->metadata->getAllMetadata());
             $this->info('Schema has been created!');
         } else {
             $this->comment("Warning: this command can cause data loss. Run with --sql or --commit.");
         }
     }
 }
开发者ID:opensolutions,项目名称:doctrine2bridge-l5,代码行数:16,代码来源:Create.php

示例5: testGetCreateSchemaSql3

 public function testGetCreateSchemaSql3()
 {
     $classes = array($this->_em->getClassMetadata('Doctrine\\Tests\\Models\\Generic\\BooleanModel'));
     $tool = new SchemaTool($this->_em);
     $sql = $tool->getCreateSchemaSql($classes);
     $this->assertEquals(1, count($sql));
     $this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:MySqlSchemaToolTest.php

示例6: getBundleSqlSchema

 private function getBundleSqlSchema()
 {
     $sql = array();
     foreach ($this->_application->getBundles() as $bundle) {
         $classes = $this->_getBundleSchema($bundle);
         $sql = array_merge($sql, $this->_schemaTool->getCreateSchemaSql($classes));
     }
     return $sql;
 }
开发者ID:nietzcheson,项目名称:BackBee,代码行数:9,代码来源:Database.php

示例7: testGetCreateSchemaSql3

 public function testGetCreateSchemaSql3()
 {
     $classes = array($this->_em->getClassMetadata('Doctrine\\Tests\\Models\\Generic\\BooleanModel'));
     $tool = new SchemaTool($this->_em);
     $sql = $tool->getCreateSchemaSql($classes);
     $this->assertEquals(2, count($sql));
     $this->assertEquals("CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))", $sql[0]);
     $this->assertEquals("CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[1]);
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:9,代码来源:PostgreSqlSchemaToolTest.php

示例8: testGetCreateSchemaSql

 public function testGetCreateSchemaSql()
 {
     $driver = new \Doctrine\Tests\Mocks\DriverMock();
     $conn = new \Doctrine\Tests\Mocks\ConnectionMock(array(), $driver);
     $conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform());
     $em = $this->_getTestEntityManager($conn);
     $classes = array($em->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsAddress'), $em->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser'), $em->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsPhonenumber'));
     $exporter = new SchemaTool($em);
     $sql = $exporter->getCreateSchemaSql($classes);
     $this->assertEquals(count($sql), 8);
 }
开发者ID:jackbravo,项目名称:doctrine,代码行数:11,代码来源:SchemaToolTest.php

示例9: executeSchemaCommand

 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     if ($input->getOption('dump-sql') === true) {
         $sqls = $schemaTool->getCreateSchemaSql($metadatas);
         $output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL);
     } else {
         $output->write('Creating database schema...' . PHP_EOL);
         $schemaTool->createSchema($metadatas);
         $output->write('Database schema created successfully!' . PHP_EOL);
     }
 }
开发者ID:roydonstharayil,项目名称:sugarbox,代码行数:11,代码来源:CreateCommand.php

示例10: executeSchemaCommand

 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     $output->write('ATTENTION: This operation should not be executed in an production enviroment.' . PHP_EOL . PHP_EOL);
     if ($input->getOption('dump-sql') === true) {
         $sqls = $schemaTool->getCreateSchemaSql($metadatas);
         $output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL);
     } else {
         $output->write('Creating database schema...' . PHP_EOL);
         $schemaTool->createSchema($metadatas);
         $output->write('Database schema created successfully!' . PHP_EOL);
     }
 }
开发者ID:jeffreiffers,项目名称:doctrine2,代码行数:12,代码来源:CreateCommand.php

示例11: generate

 /**
  * Generate SQL for creating schema
  *
  * @return string
  */
 public function generate()
 {
     AnnotationRegistry::registerFile(__DIR__ . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     $driver = new AnnotationDriver(new CachedReader(new AnnotationReader(), new ArrayCache()), array(__DIR__ . '/../library/Xi/Filelib/Backend/Adapter/DoctrineOrm/Entity'));
     $config = new Configuration();
     $config->setMetadataDriverImpl($driver);
     $config->setProxyDir(ROOT_TESTS . '/data/temp');
     $config->setProxyNamespace('Proxies');
     $em = EntityManager::create($this->connectionOptions, $config);
     $st = new SchemaTool($em);
     $metadata = $st->getCreateSchemaSql($em->getMetadataFactory()->getAllMetadata());
     return join(";\n", $metadata) . ";\n";
 }
开发者ID:kankje,项目名称:xi-filelib,代码行数:18,代码来源:generate-schema.php

示例12: installPluginSchema

 /**
  * Install plugin schema based on Doctrine metadata
  *
  * @param array         $metadata
  * @param MauticFactory $factory
  *
  * @throws \Doctrine\DBAL\ConnectionException
  * @throws \Doctrine\ORM\ORMException
  * @throws \Exception
  */
 public static function installPluginSchema(array $metadata, MauticFactory $factory)
 {
     $db = $factory->getDatabase();
     $schemaTool = new SchemaTool($factory->getEntityManager());
     $installQueries = $schemaTool->getCreateSchemaSql($metadata);
     $db->beginTransaction();
     try {
         foreach ($installQueries as $q) {
             $db->query($q);
         }
         $db->commit();
     } catch (\Exception $e) {
         $db->rollback();
         throw $e;
     }
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:26,代码来源:PluginBundleBase.php

示例13: executeSchemaCommand

 /**
  * {@inheritdoc}
  */
 protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
 {
     if ($input->getOption('dump-sql')) {
         $sqls = $schemaTool->getCreateSchemaSql($metadatas);
         $output->writeln(implode(';' . PHP_EOL, $sqls) . ';');
     } else {
         $output->writeln('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL);
         $output->writeln('Creating database schema...');
         $schemaTool->createSchema($metadatas);
         $output->writeln('Database schema created successfully!');
     }
     // Insert fake data to database
     if ($input->getOption('fakedata')) {
         $this->_insertFakeData($output);
     }
     return 0;
 }
开发者ID:bsa-git,项目名称:silex-mvc,代码行数:20,代码来源:CreateCommand.php

示例14: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     if (!$this->option('sql')) {
         $this->error('ATTENTION: This operation should not be executed in a production environment.');
     }
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $tool = new SchemaTool($em);
         $this->message('Creating database schema for <info>' . $name . '</info> entity manager...', 'blue');
         if ($this->option('sql')) {
             $sql = $tool->getCreateSchemaSql($em->getMetadataFactory()->getAllMetadata());
             $this->comment('     ' . implode(';     ' . PHP_EOL, $sql));
         } else {
             $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
         }
     }
     $this->info('Database schema created successfully!');
 }
开发者ID:rosstuck,项目名称:Laravel-Doctrine,代码行数:24,代码来源:SchemaCreateCommand.php

示例15: _doRun

 protected function _doRun(HelperSet $helperSet)
 {
     if ($this->installSqlFile === null) {
         throw new \BuildException("Schema SQL file is not set.");
     }
     if (!is_dir(dirname($this->installSqlFile))) {
         throw new \BuildException("Schema SQL directory is not a valid directory.");
     }
     if (!is_writable(dirname($this->installSqlFile))) {
         throw new \BuildException("Schema SQL directory is not writable.");
     }
     $emHelper = $helperSet->get('em');
     $em = $emHelper->getEntityManager();
     $schemaTool = new SchemaTool($em);
     $cmf = $em->getMetadataFactory();
     $classes = $cmf->getAllMetadata();
     $sql = $schemaTool->getCreateSchemaSql($classes);
     $code = sprintf("<?php\n\nreturn %s;\n", var_export($sql, true));
     file_put_contents($this->installSqlFile, $code);
     $this->log("Wrote schema SQL to file {$this->installSqlFile}");
 }
开发者ID:Credit-Jeeves,项目名称:DoctrineExtensions,代码行数:21,代码来源:InstallSql.php


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