并在 LEFT JOIN 中加入 Doctrine
AND in LEFT JOIN with Doctrine
我怎样才能像这样在 LEFT JOIN 中添加 AND SELECT * FROM photo LEFT JOIN liked_photo lp on photo.id = lp.photo_id AND lp.user_id = 6 其中 photo.is_public = 1 ?
`{`
`return $this->createQueryBuilder('photo')`
`->leftJoin("photo.likedPhotos", "lp", "photo.id = lp.Photo")`
`->addSelect('lp')`
`->where('photo.is_public = 1')`
`->orderBy('photo.uploaded_at', 'DESC')`
`->getQuery();`
}
试试 :
return $this->createQueryBuilder('photo')
->leftJoin("photo.likedPhotos", "lp", Join::WITH, "photo.id = lp.Photo AND lp.user_id = 6")
->addSelect('lp')
->where('photo.is_public = 1')
->orderBy('photo.uploaded_at', 'DESC')
->getQuery();
我怎样才能像这样在 LEFT JOIN 中添加 AND SELECT * FROM photo LEFT JOIN liked_photo lp on photo.id = lp.photo_id AND lp.user_id = 6 其中 photo.is_public = 1 ?
`{`
`return $this->createQueryBuilder('photo')`
`->leftJoin("photo.likedPhotos", "lp", "photo.id = lp.Photo")`
`->addSelect('lp')`
`->where('photo.is_public = 1')`
`->orderBy('photo.uploaded_at', 'DESC')`
`->getQuery();`
}
试试 :
return $this->createQueryBuilder('photo')
->leftJoin("photo.likedPhotos", "lp", Join::WITH, "photo.id = lp.Photo AND lp.user_id = 6")
->addSelect('lp')
->where('photo.is_public = 1')
->orderBy('photo.uploaded_at', 'DESC')
->getQuery();