Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine - check if record exists based on field

Using doctrine in symfony2, i have a simple user model with the following fields:

Username
Email
Password

How can I load the model based on email address?

like image 821
Marty Wallace Avatar asked Feb 08 '13 21:02

Marty Wallace


Video Answer


1 Answers

$user = $this->getDoctrine()
             ->getRepository('YourBundle:User')
             ->findOneBy(array('email' => $email));

Please read the official doctrine orm documentation about this

like image 114
seferov Avatar answered Oct 14 '22 03:10

seferov