-1

我想查找是否$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()
    ;
}
4

1 回答 1

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()
    ;
}
于 2020-04-17T13:21:43.323 回答