當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。