Query builder select entity relation id
Asked Answered
E

1

7

I have some query and I need in select block select id relation entity, how can I do it without some join, like in SQL? In example I add leftJoin but I want understand it's possible without join like lsc.serviceCompany.id or how ?

        $qb
        ->select('
            ser_com.id as serviceCompanyId 
        ')
        ->from('AppBundle:LocationServiceCompany', 'lsc')
        ->leftJoin('lsc.serviceCompany', 'ser_com')
        ->where('lsc.serviceCompany = :sc')
        ->setParameter('sc', $serviceCompany);
Ejaculate answered 6/4, 2017 at 7:35 Comment(0)
C
16
$qb->select(IDENTITY(lsc.serviceCompany)) (...)

Duplicate of this question

Chokedamp answered 6/4, 2017 at 7:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.