Sulu\Bundle\ContactBundle\Entity\ContactRepository::findContactWithAccountsById PHP Method

findContactWithAccountsById() public method

    public function findContactWithAccountsById($id)
    {
        // Create basic query
        $qb = $this->createQueryBuilder('c')->leftJoin('c.accountContacts', 'accountContacts')->leftJoin('accountContacts.account', 'account')->addSelect('accountContacts')->addSelect('account')->where('c.id=:id')->orderBy('accountContacts.main', 'DESC');
        $query = $qb->getQuery();
        $query->setParameter('id', $id);
        try {
            $contact = $query->getSingleResult();
            return $contact;
        } catch (NoResultException $nre) {
            return;
        }
    }