I have a Symfony2 project with a MySQL db:
#app/config/config.yml
doctrine:
dbal:
driver: %database_driver% # <
host: %database_host% # |
port: %database_port% # | Defined in
dbname: %database_name% # | parameters.ini
user: %database_user% # |
password: %database_password% # <
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
Now I’d like to make simple queries (like routine calls) to an other database.
Should I define an other dbal into the config file ?
If yes, how can it be configured while keeping the default connection for the project ?
Do I have to configure an orm for each connection ?
You need to add another level of configuration and also use multiple entity managers as Doctrine uses 1 entity manager per database connection .. your configuration might look something like this :
Then you define your multiple entity managers as so
then in your action you can use the following to get the correct entity manager :
depending on which entity manager you required