-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

0

1 Answer 1

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();
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.