Doctrine join enitiy or null
Posted
by
Medvedev
on Stack Overflow
See other posts from Stack Overflow
or by Medvedev
Published on 2013-11-07T15:51:39Z
Indexed on
2013/11/07
15:53 UTC
Read the original article
Hit count: 245
I have an entity Entity\User with avatar:
/**
* @ORM\OneToOne(targetEntity="Entity\Avatar", cascade={"remove"}, fetch="LAZY")
*/
protected $avatar;
And Entity\Message entity
/**
* @ORM\ManyToOne(targetEntity="Entity\User")
*/
protected $user;
When i try to load all messages with users and avatars. But not all user have avatar.
SELECT m, u, a
FROM Entity\Message m
JOIN m.user u
JOIN u.avatar a
ORDER BY m.id DESC
How to load all messages with user who avatars and who does not have?
© Stack Overflow or respective owner