2013-09-24 44 views
2

我在實體本身看到我可以將set the schema作爲一個選項,但有沒有在公共模式之外生成實體的選項?doctrine在公共模式之外生成實體

這裏是公共架構是什麼在起作用

php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force 
php app/console doctrine:mapping:import AcmeBlogBundle annotation 
php app/console doctrine:generate:entities AcmeBlogBundle 

也許是這樣的:

php app/console doctrine:mapping:convert xml schema=Foo ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force 

僅供參考,我們使用PostgreSQL 8.x的& 9.x中作爲我們的數據庫& Symfony的2.1.3如果那麼重要

更新:

我想這就是我正在尋找,但需要一種方法來設置模式陣列值:

/** 
* Sets the table name. 
* 
* @param string $name 
* 
* @return ClassMetadataBuilder 
*/ 
public function setTable($name) 
{ 
    $this->cm->setPrimaryTable(array('name' => $name)); 

    return $this; 
} 

更新#2

我想這可能是可能在連接配置中設置此項

原始配置

# Doctrine Configuration 
doctrine: 
    dbal: 
     default_connection: my_database 
     connections: 
     my_database: 
      driver: pdo_pgsql 
      port:  5432 
      dbname: bar 
      user:  foo_user 
      password: foo_pass 
      charset: UTF8 

集的模式:

# Doctrine Configuration 
doctrine: 
    dbal: 
     default_connection: my_database 
     connections: 
     my_database: 
      driver: pdo_pgsql 
      port:  5432 
      dbname: bar/Foo 
      user:  foo_user 
      password: foo_pass 
      charset: UTF8 

回答

0

只是想指出,如果你:

ALTER USER foo_user SET search_path=foo; 

然後沒有指定一切都將在創建架構foo。如果你不能在Doctrine中解決它,你可以在PostgreSQL中解決它。

0

我使用Symfony 3,我有3種不同的模式。要生成實體我用--filter選項e.g:

./bin/console doctrine:mapping:import --force --filter="Schema_name." MyBundle xml 

然後執行其他命令生成的實體。對我來說完美的工作

編輯。 最後一件事,架構名稱必須以大寫字母開頭

相關問題