错误
In QueryException.php line 54:
[Syntax Error] line 0, col 147: Error: Expected end of string, got 'ON'
In QueryException.php line 43:
SELECT eventListingImage FROM App\Entity\EventListingImage eventListingImage LEFT JOIN eventListingImage.newEventListingImage newEventListingImage ON newEventListingImage.eventListing = eventListingImage.eventListing WHERE newEventListingImage.eventListingImag
e IS NULL
要求
$c = $this->eventListingImageRepository->createQueryBuilder('eventListingImage')
->select('eventListingImage')
->leftJoin(
'eventListingImage.newEventListingImage',
'newEventListingImage',
Join::ON,
'newEventListingImage.eventListing = eventListingImage.eventListing'
)
->andWhere('newEventListingImage.eventListingImage IS NULL')
->getQuery()
->getResult();
在 \App\Entity\NewEventListingImage::$eventListingImage
/**
* @ORM\OneToOne(targetEntity="App\Entity\EventListingImage", mappedBy="newEventListingImage")
*
* @var EventListingImage|null
*/
private $eventListingImage;
在 \App\Entity\EventListingImage::$newEventListingImage
/**
* @ORM\OneToOne(targetEntity="App\Entity\NewEventListingImage", inversedBy="eventListingImage")
* @JoinColumn(name="event_listing_id", referencedColumnName="event_listing_id")
*
* @var EventListing|null
*/
private $newEventListingImage;
我想收到一个请求
select event_listing_image.*
from event_listing_image
left join image i on event_listing_image.event_listing_id = i.event_listing_id
where i.id is null
如果使用
->leftJoin(
'eventListingImage.newEventListingImage',
'newEventListingImage'
)
然后一个错误
In QueryException.php line 215:
A single-valued association path expression to an inverse side is not supported in DQL queries. Instead of "newEventListingImage.eventListingImage" use an explicit join.
试试看:
通过子查询结果