For using multiple entitymanager in same bundle you have to config mapping options for each entitymanager.
http://symfony.com/doc/current/reference/configuration/doctrine.html
Exemple off config file
doctrine:
dbal:
default_connection: default
connections:
default:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
second:
driver: %database_sqlite_driver%
host: ~
port: ~
dbname: %database_sqlite_shop_name%
path: %database_sqlite_shop_name%
user: ~
password: ~
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
YourBundle:
# you must specify the type
type: "annotation"
# The directory for entity (relative to bundle path)
dir: "Entity/FirstDb"
#the prefix
prefix: "YourBundleEntityFirstDb"
shop:
connection: second
mappings:
YourBundle:
type: "annotation"
#here the second path where entity for the connection stand
dir: "Entity/SecondDb"
#the prefix
prefix: "YourBundleEntitySecondDb"
You can now use console for managing your db with the --em parameter
Ex : update database for shop entitymanager
php app/console doctrine:schema:update --em=shop
Read mapping information from YourBundleEntitySecondDb
Ex : update database for default entitymanager
php app/console doctrine:schema:update
Read mapping information from YourBundleEntityFirstDb
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…