Open foaly-nr1 opened 8 years ago
@foaly-nr1 did you find a workaround for this issue?
@mlocati you can use a DQL query as a workaround.
@foaly-nr1 I have a few problems writing the DQL...
$entityManager->createQuery(<<<'EOT'
SELECT t0
FROM Post t0
INNER JOIN Tag t1 WITH ?????
WHERE t1.id = :tagID
EOT
)->execute(['tagID' => 1]);
What should I write instead of ?????
? Any hint?
I found the solution:
$entityManager->createQuery(<<<'EOT'
SELECT t0
FROM Post t0
INNER JOIN Post.tags t1
WHERE t1.id = :tagID
EOT
)->execute(['tagID' => 1]);
I believe that since https://github.com/doctrine/doctrine2/pull/885, Criteria supports many-to-many associations (@bakura10, @beberlei, @teohhanhui). I created two entities and test queries in a symfony standard edition branch to illustrate this:
However, there seem to be several problems:
I added a method
__toString()
returning the id to see what happens. Now we're closer to the objective, but the SQL is missing a join:Desired query:
This problem was previously reported in https://github.com/doctrine/doctrine2/issues/5951 (@Michal-sk).