P
P
postgresdev2019-06-11 17:31:40
symfony
postgresdev, 2019-06-11 17:31:40

How to use an array to search in findBy in Symfony?

You need to search for a large number of user ids
documentUserRepository->findBy(['user' => [...], 'account' => $this->account, 'document' => $document]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
user49981, 2019-06-11
@postgresdev

class DocumentUserRepository extends EntityRepository
{
    public function findByUserAccountDocument(array $users, $account, $document)
    {
        return $this->createQueryBuilder('a')
            ->andWhere('a.user IN (:users)')->setParameter('users', $users)
            ->andWhere('a.account = :account')->setParameter('account', $account)
            ->andWhere('a.document = :document')->setParameter('document', $document)
            ->getQuery()->getResult();
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question