Marty Wallace
Marty Wallace

Reputation: 35734

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?

Upvotes: 8

Views: 24368

Answers (1)

seferov
seferov

Reputation: 4161

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

Please read the official doctrine orm documentation about this

Upvotes: 12

Related Questions