所以这就是我使用标准的方式:
$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 = ?
)
)
有什么方法可以改变括号的关联吗?
答案 0 :(得分:2)
试试这个:
$criteria = Criteria::create();
$criteria->andWhere(
$criteria->expr()->orX(
$criteria->expr()->eq('author', /**/),
$criteria->expr()->eq('author', /**/),
$criteria->expr()->eq('author', /**/)
)
);