Inner join and left join Doctrine symfony

0

Hi, I want to do an inner join with a left join to join the data I need from several tables, the normal query works for me, but when I pass it to the doctrine format I do not know how to accommodate the syntax

 SELECT
      c.id,c.'name',c.'status',c.created_at,
c.update_at,r.'name' as state, ra.carrier_id as carry  
FROM
    city c
inner JOIN
    region r on (c.'region_id' = r.id)
left JOIN
    rate ra on (c.id = ra.destination_id)    
ORDER BY
    c.id ASC

with doctrine

$qb =   $em->createQueryBuilder()
   ->select('c.id,c.name,c.status,c.createdAt,c.updateAt,r.name as state,ra.carrier as carry')
   ->from('AppBundle:city','c')
   ->innerJoin('AppBundle:region', 'r')
   ->leftJoin('AppBundle:rate','ra', Expr\Join::ON,'c.id = ra.destination')
   ->where('c.region = r.id')

   ->setMaxResults($length)
   ->setFirstResult($start)
   ->orderBy('c.'.$fiel, $dir);
if(isset($search['value']) && !empty($search['value'])){
   $qb->where("c.id like '{$search['value']}' or c.name like '%{$search['value']}%' ");
}

In symfony the error appears [Syntax Error] line 0, col 144: Error: Expected Literal, got 'JOIN'

thanks for your attention

    
asked by Daniel Rueda 13.03.2018 в 18:18
source

0 answers