mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Join second entity if record available #6254
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @johnmitz on GitHub (Jun 21, 2019).
Originally assigned to: @Ocramius on GitHub.
The issue I am facing now is I have two entities, where I can't modify first entity.
Example of first entity
Example of second entity:
Now what I need to do is to fetch all products and include orders if they are available for the product, if not I can just add field with false value or something, but products even which has no orders, still has to be fetched. Is this possible?
@Ocramius commented on GitHub (Jun 22, 2019):
SELECT p, o FROM Product p LEFT JOIN p.orders oThis gives you
Productinstances with populatedOrderentries. If you don't have the association defined from theProductside, then you will need two separate DQL queries (one to fetch products, one to fetch orders by product id).