我的目标是在一个项目捆绑包中访问多个数据库。
我阅读了symfony2文档并成功完成了以下操作:
- configure multiple connections for different Bundles
generate Entities from ONE Existing Database using:
php app/console doctrine:mapping:import AcmeBlogBundle annotation php app/console doctrine:generate:entities AcmeBlogBundle
附言:我不熟悉Doctrine。所以实际上,如果有没有Doctrine的Symfony2的方法,我也会感激。
更新#1: Cerad's answer 很接近。但是还有一个问题没有解决。因为我在不同的数据库中有一些相同的表名,最好将它们组织成Entity文件夹内的单独文件夹。我已经查看了类似this和that的帖子。但是这些解决方案对我不起作用。它们的解决方案只是直接将所有实体放入Entity文件夹中,忽略了config.yml中指定的dir选项。有没有解决这个问题的方法?
Bundle/Entity/ThingsThatMakeMeMad/SpilledMilk.php
等。 - james_t