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


PHP Database::setNamespace方法代码示例

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


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

示例1: testTableNamespaceAndDbNamespace

 public function testTableNamespaceAndDbNamespace()
 {
     $d = new Database('fooDb');
     $d->setNamespace('Baz');
     $t = new Table('fooTable');
     $t->setNamespace('Foo\\Bar');
     $d->addTable($t);
     $builder = new TestableOMBuilder2($t);
     $this->assertEquals('Baz\\Foo\\Bar', $builder->getNamespace(), 'Builder namespace is composed from the database and table namespaces when both are set');
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:10,代码来源:AbstractOMBuilderNamespaceTest.php

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

示例3: testAddTable

 public function testAddTable()
 {
     $table = $this->getTableMock('books', ['namespace' => 'Acme\\Model']);
     $database = new Database();
     $database->setPackage('acme');
     $database->setNamespace('Acme\\Model');
     $database->addTable($table);
     $this->assertSame(1, $database->countTables());
     $this->assertCount(1, $database->getTablesForSql());
     $this->assertTrue($database->hasTable('books'));
     $this->assertTrue($database->hasTable('books', true));
     $this->assertFalse($database->hasTable('BOOKS'));
     $this->assertTrue($database->hasTableByPhpName('Books'));
     $this->assertSame($table, $database->getTable('books'));
     $this->assertSame($table, $database->getTableByPhpName('Books'));
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:16,代码来源:DatabaseTest.php

示例4: testAddTableSkipsDatabaseNamespaceWhenTableNamespaceIsAbsolute

 public function testAddTableSkipsDatabaseNamespaceWhenTableNamespaceIsAbsolute()
 {
     $db = new Database();
     $db->setNamespace('Foo');
     $t1 = new Table('t1');
     $t1->setNamespace('\\Bar');
     $db->addTable($t1);
     $this->assertEquals('Bar', $t1->getNamespace());
 }
开发者ID:norfil,项目名称:Propel2,代码行数:9,代码来源:DatabaseTest.php

示例5: 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);
     $this->getNamespace() && $database->setNamespace($this->getNamespace());
     $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:naldz,项目名称:cyberden,代码行数:39,代码来源:ReverseManager.php


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