Doctrine join enitiy or null
- by Medvedev
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?