If you look in the section โHow to work with several managers and community connectionsโ in the documentation, you will notice that you can bind your package objects to one or many object managers . Each of them is associated with a specific connection to the database.
If, for example, I defined two database connections (first_connection and second_connection), I can add two entity managers, as follows,
entity_managers: first_manager: connection: first_connection mappings: MyBundle: dir: Path/To/EntityFolder/Foo/ second_manager: connection: second_connection mappings: MyBundle: dir: Path/To/EntityFolder/Bar/
You can then specify which correct Entity Manager to use during the first two steps of the entity creation process,
php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force --em=first_manager --filter=MyTable
Note. The --filter used so that you can create your objects individually.
php app/console doctrine:mapping:import AcmeBlogBundle annotation --em=first_manager --filter=MyTable php app/console doctrine:generate:entities AcmeBlogBundle
Then your entities are placed in the necessary folders in accordance with the connection to which they are attached.
Ahmed Siouani Nov 29 '12 at 20:41 2012-11-29 20:41
source share