我正在尝试将映射表与关联的ID相关联。
mapping_table
id service_receiver_id service_provider_id
1 1 2
2 4 1
如何编写doctrine查询以检索映射到...
的1我需要像
这样的结果associated_with
2
4
在我的情况下,我使用了这个查询:
$qb->select('om', 'o', 'ot')
->from('Organization\Entity\OrgMapping', 'om')
->leftJoin('om.organization', 'o')
->where('om.organization = :hspId')
->setParameter('hspId', $hspId);
仅查询结果
//List of Associates that is Mapped Already
$organizations = $this->orgMappingRepository->listAssociatesByHSPId($hspId, $mapType, $filterBy, $searchBy, $pageNo, $paginationArr);
$mappedAssociates = array();
foreach ($organizations as $org) {
$mappedAssociates[$org->getServiceProvider()->getId()] = array(
'id' => $org->getServiceProvider()->getId(),
'name' => $org->getServiceProvider()->getName(),
'orgType' => $org->getServiceProvider()->getOrgType()->getName(),
'logo' => $org->getServiceProvider()->getLogo(),
'cityName' => $org->getServiceProvider()->getCity() ? $org->getServiceProvider()->getCity()->getName() : null,
'areaName' => $org->getServiceProvider()->getArea() ? $org->getServiceProvider()->getArea()->getName() : null,
'zipcode' => $org->getServiceProvider()->getZipcode(),
);
}
the result i am getting is :
id service_receiver_id service_provider_id
1 1 2