0
Consider the following configuration file:
config.yml
doctrine:
dbal:
default_connection: slqX45
connections:
slqX44:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
slqX45:
driver: pdo_mysql
host: "%database_host_co%"
port: "%database_port_co%"
dbname: "%database_name_co%"
user: "%database_user_co%"
password: "%database_password_co%"
charset: UTF8
Note that the connection marked as default is sqlX45
.
However I have some entities that have their respective tables in the database A
and others in the database B
, so the need to use 2 connections.
When executing the following commands on the console, I need to specify which connection to use and which entity to use, for example:
app/console doctrine:generate:entities --entidade="EntidadeA" --conexao="slqX44"
app/console doctrine:schema:update --entidade="EntidadeA" --conexao="slqX44"
How to do this?
Thanks for your time. In the meantime I have seen the documentation but I can’t find a way to configure which "Entity manager" each entity will be in. I only found way to indicate in the "mappings" which Bundle and in my case the 2 entities belong to the same, but in different databases.
– Filipe Moraes
You can tell which entities will be part of each manager Ntity, even if they are in the same manager. See the solution to this question: http://stackoverflow.com/questions/9311485/working-with-two-entity-managers-in-the-same-bundle-in-symfony2
– Rodrigo Rigotti