如何更改学说标准中的命令顺序

How to change order of commands in doctrine Criteria

这就是我使用标准的方式:

$criteria = Criteria::create();
$criteria->andWhere($criteria->expr()->eq('author', /**/));
$criteria->orWhere($criteria->expr()->eq('author', /**/));
$criteria->orWhere($criteria->expr()->eq('author', /**/));

导致此 sql 命令:

WHERE 

      (
        (
          t0.author_id = ? 
          OR t0.author_id = ?
        ) 
        OR t0.author_id = ?
      ) 

如果我需要这个怎么办?

WHERE 

      (
        (
          t0.author_id = ? 
          OR t0.author_id = ?
          OR t0.author_id = ?
        )
      ) 

有什么办法可以改变括号的关联吗?

试试这个:

$criteria = Criteria::create();
$criteria->andWhere(
    $criteria->expr()->orX(
        $criteria->expr()->eq('author', /**/),
        $criteria->expr()->eq('author', /**/),
        $criteria->expr()->eq('author', /**/)
    )
);