Heim > Fragen und Antworten > Hauptteil
Ich muss Daten aus zwei Datenbanken im Controller abrufen. Wie mache ich das?
http://symfony.cn/docs/cookbook/doctrine/multiple_entity_managers.html...
Ich habe nach dieser Antwort gesucht, aber nachdem ich ihr gefolgt bin, hat sie nicht funktioniert
習慣沉默2017-05-16 16:46:17
获取数据库 A 实例
$emA = $this->get('doctrine')->getManager('default');
获取数据 B 实例
$emB = $this->get('doctrine')->getManager('customer');
从 A 实例的 product 实体中取得数据
$productsA = $emA->getRepository('AppBundle:Product')->findAll();
从 B 实例的 product 实体中取得数据
$productsB = $emB->getRepository('AppBundle:Product')->findAll();