在学说中制作komplex标准过滤器

时间:2015-10-21 14:31:07

标签: doctrine-orm zend-framework2

获得了该查询:

$criteria = new \Doctrine\Common\Collections\Criteria();
        $criteria
            ->where($criteria->expr()->eq('collection', $post['id']))
            ->andWhere($criteria->expr()->eq('path', ''))
            ->orWhere($criteria->expr()->eq('path', '/'));

执行类似

的查询
where collecion = 1 and path = '' or path = '/'

但怎么说:

where collecion = 1 and (path = '' or path = '/')

cu n00n

1 个答案:

答案 0 :(得分:1)

试试这个:

    $criteria = new \Doctrine\Common\Collections\Criteria();
    $criteria
        ->where($criteria->expr()->eq('collection', $post['id']))
        ->andWhere(
            $criteria->expr()->orX(
                $criteria->expr()->eq('path', ''),
                $criteria->expr()->eq('path', '/')
            )

        );

希望这个帮助