CreateQueryBuilder, чтобы найти строку в массиве? - PullRequest
0 голосов
/ 17 апреля 2020

Я хочу узнать, существует ли $work (string) в Works (array), как мне написать запрос?

public function findByProject($project, $work)
{
    return $this->createQueryBuilder('p')
        ->andWhere('p.project_type = :project')
        ->andWhere('p.works = :work')
        ->setParameter('project', $project)
        ->setParameter('work', $work)
        ->orderBy('p.id', 'ASC')
        //->setMaxResults(10)
        ->getQuery()
        ->getResult()
    ;
}

1 Ответ

0 голосов
/ 17 апреля 2020

publi c функция findByProject ($ project, $ work)

{
    return $this->createQueryBuilder('p')
        ->andWhere('p.project_type = :project')
        ->andWhere('p.works LIKE :work')
        ->setParameter('project', $project)
        ->setParameter('work', '%'.$work.'%')
        ->orderBy('p.id', 'ASC')
        //->setMaxResults(10)
        ->getQuery()
        ->getResult()
    ;
}
...