This is the query you currently have -- it is erroring because in the WHERE clause it does not know a field named type
:
SELECT
z as task,
GROUP_CONCAT(DISTINCT o.tahoObject) as type
FROM Cloud\CrmBundle\Entity\Tasks z
LEFT JOIN z.taskOwner u
LEFT JOIN z.taskTasksHasObject o
WHERE z.taskDone = :ztaskDone
AND u.userFirstnameLastname = :uuserFirstnameLastname
AND type LIKE :type
GROUP BY z.taskId
ORDER BY z.taskDate desc
To fix this you need to restructure your query either this way by using GROUP_CONCAT in the where clause as well (but I am unsure if you can do the DISTINCT inside of the GROUP_CONCAT in the where clause - you can try it):
SELECT
z.taskId as task, -- z as task did not make sense to me
GROUP_CONCAT(DISTINCT o.tahoObject) as type
FROM Cloud\CrmBundle\Entity\Tasks z
LEFT JOIN z.taskOwner u -- ON ... is missing
LEFT JOIN z.taskTasksHasObject o -- ON ... is missing
WHERE z.taskDone = :ztaskDone
AND u.userFirstnameLastname = :uuserFirstnameLastname
AND GROUP_CONCAT(DISTINCT o.tahoObject) LIKE :type
GROUP BY z.taskId
ORDER BY z.taskDate desc
Or you may need to do a nested query:
SELECT task, type
FROM (
SELECT
z.taskId as task, -- z as task did not make sense to me
GROUP_CONCAT(DISTINCT o.tahoObject) as type
FROM Cloud\CrmBundle\Entity\Tasks z
LEFT JOIN z.taskOwner u -- ON ... is missing
LEFT JOIN z.taskTasksHasObject o -- ON ... is missing
WHERE z.taskDone = :ztaskDone
AND u.userFirstnameLastname = :uuserFirstnameLastname
GROUP BY z.taskId
ORDER BY z.taskDate desc
) x
WHERE x.type LIKE :type
I would also like to point out that you appear to be missing join conditions on both your LEFT JOINS. Also, selecting z as task
does not make sense to me. Perhaps you meant z.taskId as task
? Good luck!