Search code examples
zend-frameworkdoctrine-orm

Doctrine ORM zend framework entitymanager findby multiple conditions


I'm querying the database with 2 findby's, is there a way to do it in one findby with 2 conditions?

$this->entityManager->getRepository(User::class)->findOneByConfirmtoken($token)
        && $this->entityManager->getRepository(User::class)->findOneById($id)

Solution

  • ->findBy([
        'property1' => 'value1',
        'property2' => 'value2',
    ])
    

    See the docs about using conditions