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


PHP Comparator::compareSchemas方法代码示例

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


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

示例1: testCompareChangedIndexFieldPositions

 public function testCompareChangedIndexFieldPositions()
 {
     $schema1 = new Schema(array('bugdb' => new Table('bugdb', array('integerfield1' => new Column('integerfield1', Type::getType('integer')), 'integerfield2' => new Column('integerfield2', Type::getType('integer'))), array('primary' => new Index('primary', array('integerfield1', 'integerfield2'), true)))));
     $schema2 = new Schema(array('bugdb' => new Table('bugdb', array('integerfield1' => new Column('integerfield1', Type::getType('integer')), 'integerfield2' => new Column('integerfield2', Type::getType('integer'))), array('primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)))));
     $expected = new SchemaDiff(array(), array('bugdb' => new TableDiff('bugdb', array(), array(), array(), array(), array('primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)))));
     $actual = Comparator::compareSchemas($schema1, $schema2);
     $this->assertEquals($expected, $actual);
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:8,代码来源:ComparatorTest.php

示例2: setupSchema

 /**
  * Creates all required tables from schema if they don't exist
  */
 protected function setupSchema(array $files, $clean = false)
 {
     foreach ($files as $rname => $filepath) {
         $this->msg('Using schema from ' . basename($filepath), 1);
         $this->status('');
         if (($list = (include $filepath)) === false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('Unable to get list from file "%1$s"', $filepath));
         }
         $dbal = $this->getConnection($rname)->getRawObject();
         if (!$dbal instanceof \Doctrine\DBAL\Connection) {
             throw new \Aimeos\MW\Setup\Exception('Not a DBAL connection');
         }
         $dbalschema = new \Doctrine\DBAL\Schema\Schema();
         $dbalManager = $dbal->getSchemaManager();
         $platform = $dbal->getDatabasePlatform();
         $schema = $this->getSchema($rname);
         if (isset($list['table'])) {
             foreach ((array) $list['table'] as $name => $fcn) {
                 $this->msg(sprintf('Checking table "%1$s": ', $name), 2);
                 $table = $dbalManager->listTableDetails($name);
                 $tables = $table->getColumns() !== array() ? array($table) : array();
                 $tableSchema = new \Doctrine\DBAL\Schema\Schema($tables);
                 $schemaDiff = \Doctrine\DBAL\Schema\Comparator::compareSchemas($tableSchema, $fcn(clone $dbalschema));
                 $stmts = $this->remove($this->exclude($schemaDiff, $list), $clean)->toSaveSql($platform);
                 $this->executeList($stmts, $rname);
                 $this->status('done');
             }
         }
         if (isset($list['sequence']) && $schema->supports($schema::HAS_SEQUENCES)) {
             $sequences = $dbalManager->listSequences();
             foreach ((array) $list['sequence'] as $name => $fcn) {
                 $this->msg(sprintf('Checking sequence "%1$s": ', $name), 2);
                 $seqSchema = new \Doctrine\DBAL\Schema\Schema(array(), $sequences);
                 $schemaDiff = \Doctrine\DBAL\Schema\Comparator::compareSchemas($seqSchema, $fcn(clone $dbalschema));
                 $stmts = $this->remove($schemaDiff, $clean)->toSaveSql($platform);
                 $this->executeList($stmts, $rname);
                 $this->status('done');
             }
         }
     }
 }
开发者ID:aimeos,项目名称:aimeos-core,代码行数:44,代码来源:TablesCreateMShop.php

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

示例4: testCompareChangedBinaryColumn

 public function testCompareChangedBinaryColumn()
 {
     $oldSchema = new Schema();
     $tableFoo = $oldSchema->createTable('foo');
     $tableFoo->addColumn('id', 'binary');
     $newSchema = new Schema();
     $table = $newSchema->createTable('foo');
     $table->addColumn('id', 'binary', array('length' => 42, 'fixed' => true));
     $expected = new SchemaDiff();
     $expected->fromSchema = $oldSchema;
     $tableDiff = $expected->changedTables['foo'] = new TableDiff('foo');
     $tableDiff->fromTable = $tableFoo;
     $columnDiff = $tableDiff->changedColumns['id'] = new ColumnDiff('id', $table->getColumn('id'));
     $columnDiff->fromColumn = $tableFoo->getColumn('id');
     $columnDiff->changedProperties = array('length', 'fixed');
     $this->assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:17,代码来源:ComparatorTest.php

示例5: testCompareChangedColumn

 public function testCompareChangedColumn()
 {
     $oldSchema = new Schema();
     $tableFoo = $oldSchema->createTable('foo');
     $tableFoo->addColumn('id', 'integer');
     $newSchema = new Schema();
     $table = $newSchema->createTable('foo');
     $table->addColumn('id', 'string');
     $expected = new SchemaDiff();
     $expected->fromSchema = $oldSchema;
     $tableDiff = $expected->changedTables['foo'] = new TableDiff('foo');
     $tableDiff->fromTable = $tableFoo;
     $columnDiff = $tableDiff->changedColumns['id'] = new ColumnDiff('id', $table->getColumn('id'));
     $columnDiff->fromColumn = $tableFoo->getColumn('id');
     $columnDiff->changedProperties = array('type');
     $this->assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:17,代码来源:ComparatorTest.php


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