doctrine2 - symfony2 Ich muss eine Verbindung zu zwei verschiedenen Datenbanken herstellen.
巴扎黑
巴扎黑 2017-05-16 16:44:17
0
1
459

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

巴扎黑
巴扎黑

Antworte allen(1)
習慣沉默

获取数据库 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();
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage