Hi guys, I am new with Doctrine 2 experiences and I have got a problem with
creating queries via DQL.
Situation:
Entity User:
class User {
/**
* @OneToOne(targetEntity = "Contact", cascade={"all"},
orphanRemoval=true, fetch="EAGER")
* @JoinColumn(name = "contact_fk", referencedColumnName = "id",
nullable = false)
*/
protected $contact;
...
}
Entity Contact:
class Contact {
/** @ORM\Column(type="string", nullable=false) */
protected $email;
...
(it has no back reference to entity User)
}
and I need to create query to fetch User via passed email. Following code
doesn't work. I got exception with explanation - [Syntax Error] line 0, col
55: Error: Expected =, <, <=, <>, >, >=, !=, got '.'
UserService:
public function getUserEmail($email) {
$qb = $this->entityManager->createQueryBuilder();
$qb->select('u')
->from('App\Model\Entities\User', 'u')
->where('u.contact.email = :email')
->setParameter('email', $email);
return $qb->getQuery()->getResult();
}
Did I make any misunderstanding of Doctrine dql?
Thx for any reply..
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.