Maybe I am missing something completely, but I cannot get it working. I only want to select User objects that are linked to User objects.
User:
class User implements AdvancedUserInterface, \Serializable
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;
// other fields ...
/**
 * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User")
 */
private $firstManager;
/**
 * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User")
 */
private $secondManager;
}
I want to select those who are firstManager or secondManager for a User. Sounds simple eh?
I thought, this would do:
public function findAllManagers()
{
    $qb = $this->createQueryBuilder('user')
        ->join('user.firstManager', 'first_manager')
        ->join('user.secondManager', 'second_manager')
        ->orWhere('first_manager = user')
        ->orWhere('second_manager = user');
    $qb = $qb->getQuery();
    return $qb->getResult();
}
But only got one result, not all three I needed. I think this is valid SQL?
 
     
     
    