本文整理汇总了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');
}
示例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;
示例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'));
}
示例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());
}
示例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;
}