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


PHP AbstractSchemaManager::createSchema方法代码示例

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


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

示例1: migrate

 /**
  * Migrates the database.
  *
  * @return Schema
  */
 public function migrate()
 {
     $diff = Comparator::compareSchemas($this->manager->createSchema(), $this->schema);
     foreach ($diff->toSaveSql($this->connection->getDatabasePlatform()) as $query) {
         $this->connection->executeQuery($query);
     }
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:12,代码来源:Utility.php

示例2: testCreateSchema

    public function testCreateSchema()
    {
        $this->createTestTable('test_table');

        $schema = $this->_sm->createSchema();

        $this->assertTrue($schema->hasTable('test_table'));
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:8,代码来源:SchemaManagerFunctionalTestCase.php

示例3: drop

 /**
  * Drop all tables.
  *
  * @param array $metadata
  * @return array
  */
 public function drop(array $metadata)
 {
     $visitor = new DropSchemaSqlCollector($this->platform);
     $schema = $this->getSchemaFromMetadata($metadata);
     $fullSchema = $this->schemaManager->createSchema();
     foreach ($fullSchema->getTables() as $table) {
         if ($schema->hasTable($table->getName())) {
             $visitor->acceptTable($table);
         }
     }
     $statements = $visitor->getQueries();
     $this->build($statements);
     return $statements;
 }
开发者ID:proai,项目名称:laravel-datamapper,代码行数:20,代码来源:Builder.php

示例4: constraintName

 public function constraintName($table, $column, $constraintType)
 {
     $schema = $this->schemaManager->createSchema();
     $unique = $primaryKey = $index = $foreignKey = null;
     extract($constraintType);
     $fieldConstraints = [];
     if ($foreignKey) {
         $foreignKeys = $schema->getTable($table)->getForeignKeys();
         /** @var $fk ForeignKeyConstraint */
         foreach ($foreignKeys as $fk) {
             if (in_array($column, $fk->getLocalColumns())) {
                 $fieldConstraints[] = $fk->getName();
             }
         }
     }
     return $fieldConstraints;
 }
开发者ID:eddmash,项目名称:powerorm,代码行数:17,代码来源:SchemaEditor.php

示例5: execute

 /**
  * Execute this migration version up or down and and return the SQL.
  *
  * @param string  $direction      The direction to execute the migration.
  * @param boolean $dryRun         Whether to not actually execute the migration SQL and just do a dry run.
  * @param boolean $timeAllQueries Measuring or not the execution time of each SQL query.
  *
  * @return array $sql
  *
  * @throws \Exception when migration fails
  */
 public function execute($direction, $dryRun = false, $timeAllQueries = false)
 {
     $this->sql = array();
     $transaction = $this->migration->isTransactional();
     if ($transaction) {
         //only start transaction if in transactional mode
         $this->connection->beginTransaction();
     }
     try {
         $migrationStart = microtime(true);
         $this->state = self::STATE_PRE;
         $fromSchema = $this->sm->createSchema();
         $this->migration->{'pre' . ucfirst($direction)}($fromSchema);
         if ($direction === 'up') {
             $this->outputWriter->write("\n" . sprintf('  <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n");
         } else {
             $this->outputWriter->write("\n" . sprintf('  <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n");
         }
         $this->state = self::STATE_EXEC;
         $toSchema = clone $fromSchema;
         $this->migration->{$direction}($toSchema);
         $this->addSql($fromSchema->getMigrateToSql($toSchema, $this->platform));
         if (!$dryRun) {
             if (!empty($this->sql)) {
                 foreach ($this->sql as $key => $query) {
                     $queryStart = microtime(true);
                     if (!isset($this->params[$key])) {
                         $this->outputWriter->write('     <comment>-></comment> ' . $query);
                         $this->connection->exec($query);
                     } else {
                         $this->outputWriter->write(sprintf('    <comment>-</comment> %s (with parameters)', $query));
                         $this->connection->executeQuery($query, $this->params[$key], $this->types[$key]);
                     }
                     $this->outputQueryTime($queryStart, $timeAllQueries);
                 }
             } else {
                 $this->outputWriter->write(sprintf('<error>Migration %s was executed but did not result in any SQL statements.</error>', $this->version));
             }
             if ($direction === 'up') {
                 $this->markMigrated();
             } else {
                 $this->markNotMigrated();
             }
         } else {
             foreach ($this->sql as $query) {
                 $this->outputWriter->write('     <comment>-></comment> ' . $query);
             }
         }
         $this->state = self::STATE_POST;
         $this->migration->{'post' . ucfirst($direction)}($toSchema);
         $migrationEnd = microtime(true);
         $this->time = round($migrationEnd - $migrationStart, 2);
         if ($direction === 'up') {
             $this->outputWriter->write(sprintf("\n  <info>++</info> migrated (%ss)", $this->time));
         } else {
             $this->outputWriter->write(sprintf("\n  <info>--</info> reverted (%ss)", $this->time));
         }
         if ($transaction) {
             //commit only if running in transactional mode
             $this->connection->commit();
         }
         $this->state = self::STATE_NONE;
         return $this->sql;
     } catch (SkipMigrationException $e) {
         if ($transaction) {
             //only rollback transaction if in transactional mode
             $this->connection->rollback();
         }
         if ($dryRun === false) {
             // now mark it as migrated
             if ($direction === 'up') {
                 $this->markMigrated();
             } else {
                 $this->markNotMigrated();
             }
         }
         $this->outputWriter->write(sprintf("\n  <info>SS</info> skipped (Reason: %s)", $e->getMessage()));
         $this->state = self::STATE_NONE;
         return array();
     } catch (\Exception $e) {
         $this->outputWriter->write(sprintf('<error>Migration %s failed during %s. Error %s</error>', $this->version, $this->getExecutionState(), $e->getMessage()));
         if ($transaction) {
             //only rollback transaction if in transactional mode
             $this->connection->rollback();
         }
         $this->state = self::STATE_NONE;
         throw $e;
     }
 }
开发者ID:berchapman,项目名称:ice9,代码行数:100,代码来源:Version.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param Connection $connection
  */
 public function __construct(Connection $connection)
 {
     $this->connection = $connection;
     $this->manager = $this->connection->getSchemaManager();
     $this->schema = $this->manager->createSchema();
 }
开发者ID:enyaku,项目名称:myGoogleMapsApiV3Test,代码行数:11,代码来源:Utility.php

示例7: execute

 /**
  * Execute this migration version up or down and and return the SQL.
  *
  * @param string  $direction      The direction to execute the migration.
  * @param boolean $dryRun         Whether to not actually execute the migration SQL and just do a dry run.
  * @param boolean $timeAllQueries Measuring or not the execution time of each SQL query.
  *
  * @return array $sql
  *
  * @throws \Exception when migration fails
  */
 public function execute($direction, $dryRun = false, $timeAllQueries = false)
 {
     $this->sql = [];
     $transaction = $this->migration->isTransactional();
     if ($transaction) {
         //only start transaction if in transactional mode
         $this->connection->beginTransaction();
     }
     try {
         $migrationStart = microtime(true);
         $this->state = self::STATE_PRE;
         $fromSchema = $this->sm->createSchema();
         $this->migration->{'pre' . ucfirst($direction)}($fromSchema);
         if ($direction === self::DIRECTION_UP) {
             $this->outputWriter->write("\n" . sprintf('  <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n");
         } else {
             $this->outputWriter->write("\n" . sprintf('  <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n");
         }
         $this->state = self::STATE_EXEC;
         $toSchema = clone $fromSchema;
         $this->migration->{$direction}($toSchema);
         $this->addSql($fromSchema->getMigrateToSql($toSchema, $this->platform));
         $this->executeRegisteredSql($dryRun, $timeAllQueries);
         $this->state = self::STATE_POST;
         $this->migration->{'post' . ucfirst($direction)}($toSchema);
         $this->executeRegisteredSql($dryRun, $timeAllQueries);
         if (!$dryRun) {
             if ($direction === self::DIRECTION_UP) {
                 $this->markMigrated();
             } else {
                 $this->markNotMigrated();
             }
         }
         $migrationEnd = microtime(true);
         $this->time = round($migrationEnd - $migrationStart, 2);
         if ($direction === self::DIRECTION_UP) {
             $this->outputWriter->write(sprintf("\n  <info>++</info> migrated (%ss)", $this->time));
         } else {
             $this->outputWriter->write(sprintf("\n  <info>--</info> reverted (%ss)", $this->time));
         }
         if ($transaction) {
             //commit only if running in transactional mode
             $this->connection->commit();
         }
         $this->state = self::STATE_NONE;
         return $this->sql;
     } catch (SkipMigrationException $e) {
         if ($transaction) {
             //only rollback transaction if in transactional mode
             $this->connection->rollback();
         }
         if ($dryRun === false) {
             // now mark it as migrated
             if ($direction === self::DIRECTION_UP) {
                 $this->markMigrated();
             } else {
                 $this->markNotMigrated();
             }
         }
         $this->outputWriter->write(sprintf("\n  <info>SS</info> skipped (Reason: %s)", $e->getMessage()));
         $this->state = self::STATE_NONE;
         return [];
     } catch (\Exception $e) {
         $this->outputWriter->write(sprintf('<error>Migration %s failed during %s. Error %s</error>', $this->version, $this->getExecutionState(), $e->getMessage()));
         if ($transaction) {
             //only rollback transaction if in transactional mode
             $this->connection->rollback();
         }
         $this->state = self::STATE_NONE;
         throw $e;
     }
 }
开发者ID:seferov,项目名称:migrations,代码行数:83,代码来源:Version.php

示例8: getCurrentSchema

 /**
  * Get schema the database is currently in.
  * @return Schema
  */
 public function getCurrentSchema()
 {
     return $this->schemaManager->createSchema();
 }
开发者ID:echo511,项目名称:leanmapper,代码行数:8,代码来源:DatabaseSchemaManipulator.php

示例9: createFromSchema

 /**
  * @return Schema
  */
 public function createFromSchema()
 {
     return $this->schemaManager->createSchema();
 }
开发者ID:DIPcom,项目名称:Sandmin,代码行数:7,代码来源:SchemaDiffProvider.php


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