-1

I want to find if a $work (string) exist in Works (array), how can I write the request?

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()
    ;
}
Mike Doe
  • 16,349
  • 11
  • 65
  • 88
rzp789
  • 1
  • 1

1 Answers1

0

public function 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()
    ;
}
rzp789
  • 1
  • 1