doctrine2 - symfony2 I need to connect to 2 different databases. What should I do?
巴扎黑
巴扎黑 2017-05-16 16:44:17
0
1
467

I need to obtain data from two databases in the controller, how to do it?
http://symfony.cn/docs/cookbook/doctrine/multiple_entity_managers.html...
I searched for this answer, but after doing it, it didn't work

巴扎黑
巴扎黑

reply all(1)
習慣沉默

Get database A instance

$emA = $this->get('doctrine')->getManager('default');

Get data B instance

$emB = $this->get('doctrine')->getManager('customer');

Get data from the product entity of the A instance

$productsA = $emA->getRepository('AppBundle:Product')->findAll();

Get data from the product entity of the B instance

$productsB = $emB->getRepository('AppBundle:Product')->findAll();
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template