->Where("a.private = 1")
->andWhere("a.abstractContent =:abstractContent")
->andWhere("a.comment is null")
->andWhere(
$qb->expr()->in('a.id', $this->getEntityManager()>getRepository("pushPushBundle:CommentConcern")->idCommentaireConcern($userId)))
->orWhere("a.user =:user")
->andWhere("a.private = 1")
->andWhere("a.abstractContent =:abstractContent")
->andWhere("a.comment is null")
->orWhere("a.private = 0")
->andWhere("a.abstractContent =:abstractContent")
->andWhere($qb->expr()->in('a.id', $this->getEntityManager()->getRepository("pushPushBundle:Comment")->idCommentairePublicFatherPrivate($userId)))
->andWhere("a.comment is null")
->orWhere("a.private = 0")
->andWhere(
$qb->expr()->in('a.id', $this->getEntityManager()->getRepository("pushPushBundle:Comment")->idCommentairePublicFatherPrivateConcern($userId)))
->andWhere("a.abstractContent =:abstractContent")
->andWhere("a.comment is null")
只有最后一个OR正在行走,如果我对请求执行了getSql()方法,那么在第一个sql请求中有2个括号:
SELECT u0_.id AS id0, u0_.alias AS alias1, m1_.id AS id2, m1_.url AS url3, m1_.alt AS alt4, c2_.id AS id5, c2_.text AS text6, c2_.private AS private7, c2_.created_date AS created_date8, m3_.id AS id9, m3_.url AS url10, m3_.alt AS alt11, c4_.id AS id12, c4_.text AS text13, c4_.private AS private14, c4_.created_date AS created_date15, m5_.id AS id16, m5_.url AS url17, m5_.alt AS alt18, u6_.id AS id19, u6_.sex AS sex20, u6_.firstName AS firstName21, u6_.lastName AS lastName22, u6_.alias AS alias23, u6_.mail AS mail24, u6_.phone AS phone25, u6_.mood AS mood26, u6_.createdDate AS createdDate27, u6_.lastLogin AS lastLogin28, u6_.enabled AS enabled29, u6_.roles AS roles30, m7_.id AS id31, m7_.url AS url32, m7_.alt AS alt33, c2_.abstractContent_id AS abstractContent_id34, c2_.comment_id AS comment_id35, c2_.media_id AS media_id36, c2_.user_id AS user_id37, m3_.abstractContent_id AS abstractContent_id38, c4_.abstractContent_id AS abstractContent_id39, c4_.comment_id AS comment_id40, c4_.media_id AS media_id41, c4_.user_id AS user_id42, m5_.abstractContent_id AS abstractContent_id43, u6_.media_id AS media_id44, u6_.sponsorship_id AS sponsorship_id45, m7_.abstractContent_id AS abstractContent_id46 FROM comment c2_ LEFT JOIN media m3_ ON c2_.media_id = m3_.id INNER JOIN users u0_ ON c2_.user_id = u0_.id LEFT JOIN media m1_ ON u0_.media_id = m1_.id LEFT JOIN comment c4_ ON c2_.id = c4_.comment_id AND (c4_.id IN ('115', '117')) LEFT JOIN media m5_ ON c4_.media_id = m5_.id LEFT JOIN users u6_ ON c4_.user_id = u6_.id LEFT JOIN media m7_ ON u6_.media_id = m7_.id WHERE ((((((c2_.private = 1 AND c2_.abstractContent_id = ? AND c2_.comment_id IS NULL AND c2_.id IN ('115', '117')) OR c2_.user_id = ?) AND c2_.private = 1 AND c2_.abstractContent_id = ? AND c2_.comment_id IS NULL) OR c2_.private = 0) AND c2_.abstractContent_id = ? AND c2_.id IN ('', '119') AND c2_.comment_id IS NULL) OR c2_.private = 0) AND c2_.id IN ('113', '') AND c2_.abstractContent_id = ? AND c2_.comment_id IS NULL ORDER BY c2_.created_date ASC, c4_.created_date ASC;