Doctrine DQL Can I not dot into related objects? eg. todo.todoList.project
-
16-10-2019 - |
Question
I think I am getting the error "[Syntax Error] line 0, col 194: Error: Expected =, <, <=, <>, >, >=, !=, got '.'"
Because my DQL is invalid (3rd line)?
SELECT COUNT(t.id) AS numTasks, COUNT(t.completedOn) AS numCompleted
FROM Application\Models\Todo t
WHERE t.todoList.project = :proj
AND t.assigned = :user
How can I drill down into related elements? A Project have TodoLists, TodoLists have Todos. So I am trying to get the total number of todos & completed todos where the todo comes from the specified project
Solution
Use an explicit LEFT JOIN or INNER JOIN. That would have been done under the hood anyways.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow