Doctrine 2 DQL: Can I combine these queries into 1
I am trying to combine these queries into 1
# Get completed todos
SELECT COUNT(t.id) from Application\Models\Todos t
WHERE t.parent IS NULL
AND t.todoList.project = :proj
AND t.completedOn IS NOT NULL
# Get total todos
SELECT COUNT(t.id) from Application\Models\Todos t
WHERE t.parent IS NULL
AND t.todoList.project = :proj
- A Project have Lists
- A List have Todos
- A Todo can have 1 level of children todo - In my queries, I was querying for top level todos
- A Todo have completedOn, dueOn
In another function, I want to get
- total number of tasks belo开发者_StackOverflownging to you & the project
- total number of completed tasks belonging to you & the project
- total number of incompleted tasks due today belonging to you & the project
Do I need to do it in separate queries?
If you had a flag INT completed 1/0 then yes, using a SUM and a COUNT, but in this case i dont think its possible.
精彩评论