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


PHP Database::setPlatform方法代码示例

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


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

示例1: readDatabase

 public function readDatabase()
 {
     $this->database = new Database();
     $this->database->setIdentifierQuoting(true);
     $this->database->setPlatform($this->platform);
     $this->parser->parse($this->database);
 }
开发者ID:disider,项目名称:Propel2,代码行数:7,代码来源:PlatformDatabaseBuildTimeBase.php

示例2: readDatabase

 public function readDatabase()
 {
     $this->database = new Database();
     $this->database->setSchema('migration');
     $this->database->setPlatform($this->platform);
     $this->parser->parse($this->database);
 }
开发者ID:a-melnichuk,项目名称:Movies-Demo,代码行数:7,代码来源:MigrationTestCase.php

示例3: testParse

 public function testParse()
 {
     $parser = new MysqlSchemaParser(Propel::getConnection('reverse-bookstore'));
     $parser->setGeneratorConfig(new QuickGeneratorConfig());
     $database = new Database();
     $database->setPlatform(new DefaultPlatform());
     $this->assertEquals(1, $parser->parse($database), 'One table and one view defined should return one as we exclude views');
     $tables = $database->getTables();
     $this->assertEquals(1, count($tables));
     $table = $tables[0];
     $this->assertEquals('Book', $table->getPhpName());
     $this->assertEquals(4, count($table->getColumns()));
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:13,代码来源:MysqlSchemaParserTest.php

示例4: testTableInheritsSchema

 public function testTableInheritsSchema()
 {
     $database = new Database();
     $database->setPlatform(new SchemaPlatform());
     $database->setSchema("Foo");
     $table = new Table("Bar");
     $database->addTable($table);
     $this->assertTrue($database->hasTable("Foo.Bar"));
     $this->assertFalse($database->hasTable("Bar"));
     $database = new Database();
     $database->setPlatform(new NoSchemaPlatform());
     $database->addTable($table);
     $this->assertFalse($database->hasTable("Foo.Bar"));
     $this->assertTrue($database->hasTable("Bar"));
 }
开发者ID:norfil,项目名称:Propel2,代码行数:15,代码来源:DatabaseTest.php

示例5: testParse

 /**
  * @dataProvider parseDataProvider
  */
 public function testParse($columnDDL, $expectedColumnPhpName, $expectedColumnDefaultType, $expectedColumnDefaultValue, $expectedSize, $expectedScale)
 {
     $this->con->query("create table foo ( {$columnDDL} );");
     $parser = new PgsqlSchemaParser($this->con);
     $parser->setGeneratorConfig(new QuickGeneratorConfig());
     $database = new Database();
     $database->setPlatform(new DefaultPlatform());
     // make sure our DDL insert produced exactly the SQL we inserted
     $this->assertGreaterThanOrEqual(1, $parser->parse($database), 'We parsed at least one table.');
     $table = $database->getTable('foo');
     $columns = $table->getColumns();
     $this->assertEquals(1, count($columns));
     // check out our rev-eng column info
     $defaultValue = $columns[0]->getDefaultValue();
     $this->assertEquals($expectedColumnPhpName, $columns[0]->getPhpName());
     $this->assertEquals($expectedColumnDefaultType, $defaultValue->getType());
     $this->assertEquals($expectedColumnDefaultValue, $defaultValue->getValue());
     $this->assertEquals($expectedSize, $columns[0]->getSize());
     $this->assertEquals($expectedScale, $columns[0]->getScale());
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:23,代码来源:PgsqlSchemaParserTest.php

示例6: buildModel

 /**
  * Builds the model classes from the database schema.
  *
  * @return Database The built-out Database (with all tables, etc.)
  */
 protected function buildModel()
 {
     $config = $this->getGeneratorConfig();
     $connection = $this->getConnection();
     $databaseName = $config->getConfigProperty('reverse.connection');
     $database = new Database($this->getDatabaseName());
     $database->setPlatform($config->getConfiguredPlatform($connection), $databaseName);
     $database->setDefaultIdMethod(IdMethod::NATIVE);
     $buildConnection = $config->getBuildConnection($databaseName);
     $this->log(sprintf('Reading database structure of database `%s` using dsn `%s`', $this->getDatabaseName(), $buildConnection['dsn']));
     $parser = $config->getConfiguredSchemaParser($connection, $databaseName);
     $this->log(sprintf('SchemaParser `%s` chosen', get_class($parser)));
     $nbTables = $parser->parse($database);
     $excludeTables = $config->getConfigProperty('exclude_tables');
     $tables = [];
     foreach ($database->getTables() as $table) {
         /* Was copypasted from DatabaseComparator::isTableExcluded() */
         $skip = false;
         $tablename = $table->getName();
         if (in_array($tablename, $excludeTables)) {
             $skip = true;
         } else {
             foreach ($excludeTables as $exclude_tablename) {
                 if (preg_match('/^' . str_replace('*', '.*', $exclude_tablename) . '$/', $tablename)) {
                     $skip = true;
                 }
             }
         }
         $skip && $database->removeTable($table);
     }
     $this->log(sprintf('Successfully reverse engineered %d tables', $nbTables));
     return $database;
 }
开发者ID:disider,项目名称:Propel2,代码行数:38,代码来源:ReverseManager.php

示例7: testGetColumnDDLAutoIncrement

 public function testGetColumnDDLAutoIncrement()
 {
     $database = new Database();
     $database->setPlatform($this->getPlatform());
     $table = new Table('foo_table');
     $table->setIdMethod(IdMethod::NATIVE);
     $database->addTable($table);
     $column = new Column('foo');
     $column->getDomain()->copy($this->getPlatform()->getDomainForType(PropelTypes::BIGINT));
     $column->setAutoIncrement(true);
     $table->addColumn($column);
     $expected = 'foo bigserial';
     $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column));
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:14,代码来源:PgsqlPlatformTest.php

示例8: buildModel

 /**
  * Builds the model classes from the database schema.
  *
  * @return Database The built-out Database (with all tables, etc.)
  */
 protected function buildModel()
 {
     $config = $this->getGeneratorConfig();
     $connection = $this->getConnection();
     $this->log('Reading database structure...');
     $database = new Database($this->getDatabaseName());
     $database->setPlatform($config->getConfiguredPlatform($connection));
     $database->setDefaultIdMethod(IdMethod::NATIVE);
     $parser = $config->getConfiguredSchemaParser($connection);
     $nbTables = $parser->parse($database);
     $this->log(sprintf('Successfully reverse engineered %d tables', $nbTables));
     return $database;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:18,代码来源:ReverseManager.php

示例9: testQualifiedName

 public function testQualifiedName()
 {
     $table = new Table();
     $table->setSchema("foo");
     $table->setCommonName("bar");
     $this->assertEquals($table->getName(), "bar");
     $this->assertEquals($table->getCommonName(), "bar");
     $database = new Database();
     $database->addTable($table);
     $database->setPlatform(new NoSchemaPlatform());
     $this->assertEquals($table->getName(), "bar");
     $database->setPlatform(new SchemaPlatform());
     $this->assertEquals($table->getName(), "foo.bar");
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:14,代码来源:TableTest.php

示例10: testCompareModifiedFks

 public function testCompareModifiedFks()
 {
     $db1 = new Database();
     $db1->setPlatform($this->platform);
     $c1 = new Column('Foo');
     $c2 = new Column('Bar');
     $fk1 = new ForeignKey();
     $fk1->addReference($c1, $c2);
     $t1 = new Table('Baz');
     $t1->addForeignKey($fk1);
     $db1->addTable($t1);
     $t1->doNaming();
     $db2 = new Database();
     $db2->setPlatform($this->platform);
     $c3 = new Column('Foo');
     $c4 = new Column('Bar2');
     $fk2 = new ForeignKey();
     $fk2->addReference($c3, $c4);
     $t2 = new Table('Baz');
     $t2->addForeignKey($fk2);
     $db2->addTable($t2);
     $t2->doNaming();
     $tc = new TableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->compareForeignKeys();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(1, $nbDiffs);
     $this->assertEquals(1, count($tableDiff->getModifiedFks()));
     $this->assertEquals(array('Baz_FK_1' => array($fk1, $fk2)), $tableDiff->getModifiedFks());
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:31,代码来源:PropelTableForeignKeyComparatorTest.php

示例11: testHasPlatform

 public function testHasPlatform()
 {
     $column = new Column();
     $this->assertFalse($column->hasPlatform());
     $table = new Table();
     $table->addColumn($column);
     $this->assertFalse($column->hasPlatform());
     $database = new Database();
     $database->addTable($table);
     $this->assertFalse($column->hasPlatform());
     $platform = new DefaultPlatform();
     $database->setPlatform($platform);
     $this->assertTrue($column->hasPlatform());
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:14,代码来源:ColumnTest.php

示例12: testAddTableWithSameNameOnDifferentSchema

 public function testAddTableWithSameNameOnDifferentSchema()
 {
     $db = new Database();
     $db->setPlatform(new PgsqlPlatform());
     $t1 = new Table('t1');
     $db->addTable($t1);
     $this->assertEquals('t1', $t1->getName());
     $t1b = new Table('t1');
     $t1b->setSchema('bis');
     $db->addTable($t1b);
     $this->assertEquals('bis.t1', $t1b->getName());
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:12,代码来源:DatabaseTest.php

示例13: buildModel

 /**
  * Builds the model classes from the database schema.
  *
  * @return Database The built-out Database (with all tables, etc.)
  */
 protected function buildModel()
 {
     $config = $this->getGeneratorConfig();
     $connection = $this->getConnection();
     $databaseName = $config->getConfigProperty('reverse.connection');
     $database = new Database($this->getDatabaseName());
     $database->setPlatform($config->getConfiguredPlatform($connection), $databaseName);
     $database->setDefaultIdMethod(IdMethod::NATIVE);
     $buildConnection = $config->getBuildConnection($databaseName);
     $this->log(sprintf('Reading database structure of database `%s` using dsn `%s`', $this->getDatabaseName(), $buildConnection['dsn']));
     $parser = $config->getConfiguredSchemaParser($connection, $databaseName);
     $this->log(sprintf('SchemaParser `%s` chosen', get_class($parser)));
     $nbTables = $parser->parse($database);
     $this->log(sprintf('Successfully reverse engineered %d tables', $nbTables));
     return $database;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:21,代码来源:ReverseManager.php

示例14: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $generatorConfig = $this->getGeneratorConfig(array('propel.platform.class' => $input->getOption('platform'), 'propel.reverse.parser.class' => $this->getReverseClass($input), 'propel.migration.table' => $input->getOption('migration-table')), $input);
     $this->createDirectory($input->getOption('output-dir'));
     $manager = new MigrationManager();
     $manager->setGeneratorConfig($generatorConfig);
     $manager->setSchemas($this->getSchemas($input->getOption('input-dir')));
     $connections = array();
     $optionConnections = $input->getOption('connection');
     if (!$optionConnections) {
         $connections = $generatorConfig->getBuildConnections($input->getOption('input-dir'));
     } else {
         foreach ($optionConnections as $connection) {
             list($name, $dsn, $infos) = $this->parseConnection($connection);
             $connections[$name] = array_merge(array('dsn' => $dsn), $infos);
         }
     }
     $manager->setConnections($connections);
     $manager->setMigrationTable($input->getOption('migration-table'));
     $manager->setWorkingDirectory($input->getOption('output-dir'));
     if ($manager->hasPendingMigrations()) {
         throw new RuntimeException('Uncommitted migrations have been found ; you should either execute or delete them before rerunning the \'diff\' task');
     }
     $totalNbTables = 0;
     $schema = new Schema();
     foreach ($connections as $name => $params) {
         if ($input->getOption('verbose')) {
             $output->writeln(sprintf('Connecting to database "%s" using DSN "%s"', $name, $params['dsn']));
         }
         $conn = $manager->getAdapterConnection($name);
         $platform = $generatorConfig->getConfiguredPlatform($conn, $name);
         if (!$platform->supportsMigrations()) {
             $output->writeln(sprintf('Skipping database "%s" since vendor "%s" does not support migrations', $name, $platform->getDatabaseType()));
             continue;
         }
         $database = new Database($name);
         $database->setPlatform($platform);
         $database->setDefaultIdMethod(IdMethod::NATIVE);
         $parser = $generatorConfig->getConfiguredSchemaParser($conn);
         $nbTables = $parser->parse($database, $this);
         $schema->addDatabase($database);
         $totalNbTables += $nbTables;
         if ($input->getOption('verbose')) {
             $output->writeln(sprintf('%d tables found in database "%s"', $nbTables, $name), Output::VERBOSITY_VERBOSE);
         }
     }
     if ($totalNbTables) {
         $output->writeln(sprintf('%d tables found in all databases.', $totalNbTables));
     } else {
         $output->writeln('No table found in all databases');
     }
     $appDatasFromXml = $manager->getDataModels();
     $appDataFromXml = array_pop($appDatasFromXml);
     // comparing models
     $output->writeln('Comparing models...');
     $migrationsUp = array();
     $migrationsDown = array();
     foreach ($schema->getDatabases() as $database) {
         $name = $database->getName();
         if ($input->getOption('verbose')) {
             $output->writeln(sprintf('Comparing database "%s"', $name));
         }
         if (!$appDataFromXml->hasDatabase($name)) {
             // FIXME: tables present in database but not in XML
             continue;
         }
         $databaseDiff = DatabaseComparator::computeDiff($database, $appDataFromXml->getDatabase($name));
         if (!$databaseDiff) {
             if ($input->getOption('verbose')) {
                 $output->writeln(sprintf('Same XML and database structures for datasource "%s" - no diff to generate', $name));
             }
             continue;
         }
         $output->writeln(sprintf('Structure of database was modified in datasource "%s": %s', $name, $databaseDiff->getDescription()));
         $platform = $generatorConfig->getConfiguredPlatform(null, $name);
         $migrationsUp[$name] = $platform->getModifyDatabaseDDL($databaseDiff);
         $migrationsDown[$name] = $platform->getModifyDatabaseDDL($databaseDiff->getReverseDiff());
     }
     if (!$migrationsUp) {
         $output->writeln('Same XML and database structures for all datasource - no diff to generate');
         return;
     }
     $timestamp = time();
     $migrationFileName = $manager->getMigrationFileName($timestamp);
     $migrationClassBody = $manager->getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp);
     $file = $input->getOption('output-dir') . DIRECTORY_SEPARATOR . $migrationFileName;
     file_put_contents($file, $migrationClassBody);
     $output->writeln(sprintf('"%s" file successfully created.', $file));
     if (null !== ($editorCmd = $input->getOption('editor'))) {
         $output->writeln(sprintf('Using "%s" as text editor', $editorCmd));
         shell_exec($editorCmd . ' ' . escapeshellarg($file));
     } else {
         $output->writeln('Please review the generated SQL statements, and add data migration code if necessary.');
         $output->writeln('Once the migration class is valid, call the "migrate" task to execute it.');
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:99,代码来源:MigrationDiffCommand.php

示例15: readConnectedDatabase

 /**
  * @return Database
  */
 public function readConnectedDatabase()
 {
     $this->getDatabase();
     $database = new Database();
     $database->setSchema($this->database->getSchema());
     $database->setName($this->database->getName());
     $database->setPlatform($this->getPlatform());
     $this->getParser()->parse($database);
     return $database;
 }
开发者ID:disider,项目名称:Propel2,代码行数:13,代码来源:QuickBuilder.php


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