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


PHP Database::setSchema方法代码示例

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


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

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

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

示例3: 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->setSchema('public');
     $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:SwissalpS,项目名称:Propel2,代码行数:24,代码来源:PgsqlSchemaParserTest.php

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

示例5: Table

$table3->addColumns([$column31, $column32]);
$table4 = new Table('blog_tag');
$table4->setDescription('The list of tags');
$table4->setNamespace('Blog');
$table4->setPackage('Acme.Blog');
$table4->addColumns([$column41, $column42]);
$table5 = new Table('blog_post_tag');
$table5->setNamespace('Blog');
$table5->setPackage('Acme.Blog');
$table5->setCrossRef();
$table5->addColumns([$column51, $column52]);
$table5->addForeignKeys([$fkPostTag, $fkTagPost]);
$table6 = new Table('cms_page');
$table6->setPhpName('Page');
$table6->setNamespace('Cms');
$table6->setBaseClass('Acme\\Model\\PublicationActiveRecord');
$table6->setPackage('Acme.Cms');
$table6->addColumns([$column61, $column62, $column63, $column64]);
$table6->addIndex($pageContentFulltextIdx);
$table6->addVendorInfo(new VendorInfo('mysql', ['Engine' => 'MyISAM']));
/* Database */
$database = new Database('acme_blog', new MysqlPlatform());
$database->setSchema('acme');
$database->setTablePrefix('acme_');
$database->setNamespace('Acme\\Model');
$database->setBaseClass('Acme\\Model\\ActiveRecord');
$database->setPackage('Acme');
$database->setHeavyIndexing();
$database->addVendorInfo(new VendorInfo('mysql', ['Engine' => 'InnoDB', 'Charset' => 'utf8']));
$database->addTables([$table1, $table2, $table3, $table4, $table5, $table6]);
return $database;
开发者ID:disider,项目名称:Propel2,代码行数:31,代码来源:blog-database.php

示例6: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configOptions = [];
     if ($this->hasInputOption('connection', $input)) {
         foreach ($input->getOption('connection') as $conn) {
             $configOptions += $this->connectionToProperties($conn);
         }
     }
     if ($this->hasInputOption('migration-table', $input)) {
         $configOptions['propel']['migrations']['tableName'] = $input->getOption('migration-table');
     }
     if ($this->hasInputOption('schema-dir', $input)) {
         $configOptions['propel']['paths']['schemaDir'] = $input->getOption('schema-dir');
     }
     if ($this->hasInputOption('output-dir', $input)) {
         $configOptions['propel']['paths']['migrationDir'] = $input->getOption('output-dir');
     }
     $generatorConfig = $this->getGeneratorConfig($configOptions, $input);
     $this->createDirectory($generatorConfig->getSection('paths')['migrationDir']);
     $manager = new MigrationManager();
     $manager->setGeneratorConfig($generatorConfig);
     $manager->setSchemas($this->getSchemas($generatorConfig->getSection('paths')['schemaDir'], $input->getOption('recursive')));
     $connections = [];
     $optionConnections = $input->getOption('connection');
     if (!$optionConnections) {
         $connections = $generatorConfig->getBuildConnections();
     } else {
         foreach ($optionConnections as $connection) {
             list($name, $dsn, $infos) = $this->parseConnection($connection);
             $connections[$name] = array_merge(['dsn' => $dsn], $infos);
         }
     }
     $manager->setConnections($connections);
     $manager->setMigrationTable($generatorConfig->getConfigProperty('migrations.tableName'));
     $manager->setWorkingDirectory($generatorConfig->getSection('paths')['migrationDir']);
     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;
     $reversedSchema = new Schema();
     foreach ($manager->getDatabases() as $appDatabase) {
         $name = $appDatabase->getName();
         if (!($params = @$connections[$name])) {
             $output->writeln(sprintf('<info>No connection configured for database "%s"</info>', $name));
         }
         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;
         }
         $additionalTables = [];
         foreach ($appDatabase->getTables() as $table) {
             if ($table->getSchema() && $table->getSchema() != $appDatabase->getSchema()) {
                 $additionalTables[] = $table;
             }
         }
         if ($input->getOption('disable-identifier-quoting')) {
             $platform->setIdentifierQuoting(false);
         }
         $database = new Database($name);
         $database->setPlatform($platform);
         $database->setSchema($appDatabase->getSchema());
         $database->setDefaultIdMethod(IdMethod::NATIVE);
         $parser = $generatorConfig->getConfiguredSchemaParser($conn, $name);
         $nbTables = $parser->parse($database, $additionalTables);
         $reversedSchema->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');
     }
     // comparing models
     $output->writeln('Comparing models...');
     $tableRenaming = $input->getOption('table-renaming');
     $migrationsUp = [];
     $migrationsDown = [];
     $removeTable = !$input->getOption('skip-removed-table');
     $excludedTables = $input->getOption('skip-tables');
     foreach ($reversedSchema->getDatabases() as $database) {
         $name = $database->getName();
         if ($input->getOption('verbose')) {
             $output->writeln(sprintf('Comparing database "%s"', $name));
         }
         if (!($appDataDatabase = $manager->getDatabase($name))) {
             $output->writeln(sprintf('<error>Database "%s" does not exist in schema.xml. Skipped.</error>', $name));
             continue;
         }
         $configManager = new ConfigurationManager();
//.........这里部分代码省略.........
开发者ID:disider,项目名称:Propel2,代码行数:101,代码来源:MigrationDiffCommand.php

示例7: testAutoNamespaceToDatabaseSchemaName

    public function testAutoNamespaceToDatabaseSchemaName()
    {
        $yamlConf = <<<EOF
propel:
  database:
      connections:
          mysource:
              adapter: mysql
              classname: Propel\\Runtime\\Connection\\DebugPDO
              dsn: mysql:host=localhost;dbname=mydb
              user: root
              password:
  generator:
      schema:
          autoNamespace: true
EOF;
        $configFilename = sys_get_temp_dir() . '/propel.yml';
        $filesystem = new Filesystem();
        $filesystem->dumpFile($configFilename, $yamlConf);
        $schema = 'TestSchema';
        $config = new GeneratorConfig($configFilename);
        $platform = new MysqlPlatform();
        $parentSchema = new Schema($platform);
        $parentSchema->setGeneratorConfig($config);
        $db = new Database();
        $db->setPlatform($platform);
        $db->setParentSchema($parentSchema);
        $db->setSchema($schema);
        $this->assertEquals($schema, $db->getNamespace());
    }
开发者ID:naldz,项目名称:cyberden,代码行数:30,代码来源:DatabaseTest.php


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