-1

Possible Duplicate:
Symfony2 & Doctrine: Create custom SQL-Query

I tried that on my symfony2 project :

$em = $this->getDoctrine()->getEntityManager();
$query = $em->createQuery(
        'SELECT v.voiture,o.offre,m.marque
         FROM FrontOfficeBundle:Voiture v
         INNER JOIN FrontOfficeBundle:OffreSpecial o on o.voiture_id = v.id
         INNER JOIN FrontOfficeBundle:Marque m on m.id = v.marque_id'
    );
$result = $query->getResult();

and get that erreur :

[Syntax Error] line 0, col 122: Error: Expected Doctrine\ORM\Query\Lexer::T_WITH, got 'on'

even the SQL query are correcte ! plz help

Community
  • 1
  • 1
SOufiane Fadil
  • 163
  • 4
  • 15

1 Answers1

1

You don't need the ON option for your INNER JOIN. The Doctrine Query Language already knows the mapping of your associations because you specified the class FrontOfficeBundle:Voiture in your query.

$em = $this->getDoctrine()->getEntityManager();
$query = $em->createQuery(
        'SELECT v.voiture,o.offre,m.marque
         FROM FrontOfficeBundle:Voiture v
         INNER JOIN v.offreSpecial o 
         INNER JOIN v.marque m'
    );
$result = $query->getResult();
Mick
  • 30,759
  • 16
  • 111
  • 130