我无法想出如何解决这个问题......好吧,一些代码比长篇大论更好......所以,看看
$res = $this->getEntityManager()->createQueryBuilder()
->select(array('off.id', 'off.title', 'off.lang', 'han.id as handler', 'off.handlerWebsiteId', 'off.handlerReference',
'off.vacationsNumber', 'cat.id as category', 'acs.id as activitySector', 'wop.id as workplaces',
'off.isTelework', 'off.workDescription', 'off.experienceNeeded', 'ski.id as skills',
'off.specificSkills', 'stl.id as studyLevels', 'lak.id as languageKnowledges'))
->from('UbberjobOfferBundle:Offer', 'off')
->leftJoin('UbberjobOfferBundle:Handler', 'han', 'WITH', 'off.handler = han')
->leftJoin('UbberjobOfferBundle:Category', 'cat', 'WITH', 'off.category = cat')
->leftJoin('UbberjobOfferBundle:ActivitySector', 'acs', 'WITH', 'off.activitySector = acs')
->leftJoin('off.workplaces', 'wop')
->leftJoin('off.skills', 'ski')
->leftJoin('off.studyLevels', 'stl')
->join('off.languageKnowledges', 'lak')
->orderBy('off.dateUpdate', 'desc')
->setMaxResults($items_per_page)
->setFirstResult($start)
->getQuery()
->getResult();
Doctrine返回:
...
5: {
id: 23
title: "INSTRUCTEUR AUTO-ÉCOLE (H/F)"
lang: "fr"
handler: 2
handlerWebsiteId: "14371214"
handlerReference: "1332551"
vacationsNumber: 3
category: 23
activitySector: 19
workplaces: 3
workDescription: "..."
experienceNeeded: 12
specificSkills: "..."
studyLevels: 13
languageKnowledges: 1
}-
6: {
id: 23
title: "INSTRUCTEUR AUTO-ÉCOLE (H/F)"
lang: "fr"
handler: 2
handlerWebsiteId: "14371214"
handlerReference: "1332551"
vacationsNumber: 3
category: 23
activitySector: 19
workplaces: 11
workDescription: "..."
experienceNeeded: 12
specificSkills: "..."
studyLevels: 13
languageKnowledges: 1
}
我想要的是:
6: {
id: 23
title: "INSTRUCTEUR AUTO-ÉCOLE (H/F)"
lang: "fr"
handler: 2
handlerWebsiteId: "14371214"
handlerReference: "1332551"
vacationsNumber: 3
category: 23
activitySector: 19
workplaces: [3, 11]
workDescription: "..."
experienceNeeded: 12
specificSkills: "..."
studyLevels: 13
languageKnowledges: 1
}
多对多关系导致结果行重复(请参阅工作场所)。如果将所有内容放在一个数组中,我该怎么办?
谢谢!!!