Symfony2/Doctrine QueryBuilder using andwhere()

前端 未结 2 1739
暗喜
暗喜 2021-02-05 17:57

I am using following method in a repository class to look for certain tags in my database:

public function getItemsByTag($tag, $limit = null)
{
    $tag = \'%\'.         


        
2条回答
  •  不知归路
    2021-02-05 18:14

    From the manual, the suggested way is like below:

    $qb->select(array('c'))
       ->where($qb->expr()->orx(
           $qb->expr()->eq('c.reviewed', 1),
           $qb->expr()->eq('c.enabled', 1),
           $qb->expr()->like('c.tags', '?1')
       ))
       ->orderBy('c.clicks', 'DESC'));
    

提交回复
热议问题