I trying to do some logic if my inputed form email matches one found in the database.
How do I make the comparison if the findBy’Field” returns the whole collection instead of just the field I want to compare to? I'd think it should be done without using a foreach loop as that would kinda defeat the purpose of using my findBy method.
An Example:
$formEmail = $form->get('email')->getData();
existingEmail = $em->getRepository(‘UserBundle:User’)->findOneByEmail($formEmail);
// or existingEmail = $em->getRepository(‘UserBundle:User’)->findByEmail($formEmail);
if ($formEmail == $loggedEmail){
//perform some logic here
}
try this