我尝试连接两个数据库但是当我创建一个php bin/console doctrine:schema:update --force
它返回
没有要处理的元数据类。
这是config.yml中的doctrine配置
doctrine:
dbal:
default_connection: main
connections:
main:
driver: pdo_pgsql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
rupe:
driver: pdo_pgsql
host: '%database_host2%'
port: '%database_port2%'
dbname: '%database_name2%'
user: '%database_user2%'
password: '%database_password2%'
charset: UTF8
orm:
default_entity_manager: main
entity_managers:
main:
connection: main
mappings:
Main:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/AppBundle/Entity/Main'
prefix: 'AppBundle\\Entity\\Main'
alias: Main
login:
connection: main
mappings:
LoginBundle:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/LoginBundle/Entity'
prefix: 'LoginBundle\\Entity'
alias: LoginBundle
rupe:
connection: rupe
mappings:
Rupe:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/AppBundle/Entity/Rupe'
prefix: 'AppBundle\\Entity\\Rupe'
alias: Rupe
答案 0 :(得分:1)
我在Symfony 3.4版本上获得了一个解决方案
doctrine:
dbal:
default_connection: main
connections:
main:
driver: pdo_pgsql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
rupe:
driver: pdo_pgsql
host: '%database_host2%'
port: '%database_port2%'
dbname: '%database_name2%'
user: '%database_user2%'
password: '%database_password2%'
charset: UTF8
orm:
default_entity_manager: main
entity_managers:
main:
connection: main
mappings:
AppBundle: ~
LoginBundle: ~
rupe:
connection: rupe
mappings:
RupeBundle: ~
希望它可以帮助别人!
答案 1 :(得分:0)
一旦有多个实体管理器,您必须按实体管理器运行一次命令:
php bin/console doctrine:schema:update --force --em default
php bin/console doctrine:schema:update --force --em login
php bin/console doctrine:schema:update --force --em rupe
验证架构时需要相同的内容。
我建议您在多个连接名称更改后更改连接名称。
doctrine:
dbal:
default_connection: main
connections:
main:
driver: pdo_pgsql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
rupe:
driver: pdo_pgsql
host: '%database_host2%'
port: '%database_port2%'
dbname: '%database_name2%'
user: '%database_user2%'
password: '%database_password2%'
charset: UTF8
我还会给实体经理提供描述性名称,当你将它们注入不同的服务时,它会更加清晰。