我试图配置为使用两个数据库,我有这样的配置:
doctrine:
dbal:
connections:
default:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
zaweb:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: "zyabypoel"
user: %database_user%
password: %database_password%
types:
json: Sonata\Doctrine\Types\JsonType
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
zaweb:
connection: zaweb
mappings:
ZaWebMenuBundle: ~
ZaWebGeoBundle: ~
ZaWebApiBundle: ~
ZaWebSiteBundle: ~
ZaWebAdminBundle: ~
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
result_cache_driver: apc
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
当我运行php app/console doctrine:database:create --connection=zaweb
时,我收到错误消息:
无法识别的选项"过滤器,result_cache_driver,auto_mapping"在" doctrine.orm"
当我添加第二个连接时,会出现此错误。为什么呢?
答案 0 :(得分:1)
filters
属于doctrine.orm.entity_managers.manager
。因此,您必须将此选项移到文件的右侧,因此它不在旁边,而是在实体管理器中。
auto_mapping
和result_cache_driver
也属于具体的entity_manager
,例如在zaweb
内。
见这里:http://symfony.com/doc/current/reference/configuration/doctrine.html
编辑:抱歉,现在我也搞砸了缩进。现在已经修好了。 最后 实际上看起来像这个:
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
zaweb:
connection: zaweb
result_cache_driver: apc
auto_mapping: true
mappings:
ZaWebMenuBundle: ~
ZaWebGeoBundle: ~
ZaWebApiBundle: ~
ZaWebSiteBundle: ~
ZaWebAdminBundle: ~
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
auto_generate_proxy_classes: %kernel.debug%