Symfony2 / Doctrine - Query join with three different entities

1

The way below works correctly:

$qb->select('partial t.{id,nsu,status,message}, partial u.{id,shortName,email} as user')
   ->from('GatewayBundle:Transaction', 't')
   ->join('GatewayBundle:User', 'u')
   ->where('u.id = t.user');

When I add another join , it results in a syntax error:

  

ERROR - [Syntax Error] line 0, col 461: Error: Expected Literal, got 'JOIN' 500 Internal Server Error - QueryException

$qb->select('partial t.{id,nsu,status,message}, partial u.{id,shortName,email} as user, partial p.{id} as partner')
   ->from('GatewayBundle:Transaction', 't')
   ->join('GatewayBundle:User', 'u')
   ->join('GatewayBundle:Partner', 'p')
   ->where('u.id = t.user')
   ->andWhere('p.id = t.partner');

What is the correct syntax for this type of query?

    
asked by anonymous 16.06.2014 / 19:40

1 answer

1

It worked this way:

$qb
    ->select('
        t.id, t.nsu, t.status, t.message, 
        u.id as u_id, u.shortName as u_shortName , u.email as u_email, 
        p.id as p_id, p.name as p_name')
    ->from('PaylevenGatewayBundle:Transaction', 't')
    ->join('t.user', 'u')
    ->join('t.partner', 'p');
    
26.06.2014 / 17:41