Bonjour,

J'ai un problème avec une requete dql, qui me retourne l'erreur suivante :


"tableA" with an alias of "a2" in your query does not reference the parent co
mponent it is related to.

J'ai 2 tables :

tableA
tableB

Requête en SQL qui fonctionne :
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
SELECT a1.champ1 as c1, a2.champ1 as c2
FROM tableA as a1
LEFT JOIN tableB as b1 ON a1.id = b1.id
LEFT JOIN tableB as b2 ON b1.code = b2.code
LEFT JOIN tableA as a2 ON b2.id = a2.id
WHERE a1.id = 1
Voici ce que j'ai essayé en dql :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$q = Doctrine_Query::create();
    $q -> select('a1.champ1 as c1, a2.champ1 as c2 ');
    $q -> from('tableA a1');
    $q -> leftJoin('tableB b1 ON a1.id = b1.id');
    $q -> leftJoin('tableB b2 ON b1.code = b2.code');
    $q -> leftJoin('tableA a2 ON b2.id = a2.id');
    $q -> where('a1.id = ?', 1);
 
$q = Doctrine_Query::create();
    $q -> select('a1.champ1 as c1, a2.champ1 as c2 ');
    $q -> from('tableA a1');
    $q -> leftJoin('a1.tableB b1 ON');
    $q -> leftJoin('b1.tableB b2 ON b1.code = b2.code');
    $q -> leftJoin('b2.tableA a2 ON b2.id = a2.id');
    $q -> where('a1.id = ?', 1);
Je ne vois pas trop comment retranscrire mon sql ? Pouvez-vous m'aider s'il vous plait ?