是否可以将此SQL转换为DQL:
SELECT project.*, task.*
FROM `project`
LEFT JOIN (
SELECT * FROM task
WHERE (task.title LIKE '%add%' OR task.description LIKE '%add%' )
) task ON project.id = task.project_id
WHERE project.id = 50
即使没有找到任务,我也需要返回项目。
我最初的DQL是:
SELECT p, t FROM MyBundle:Project p
LEFT JOIN p.tasks t
WHERE p.id = :id AND (t.title LIKE :title OR t.description LIKE :description)
ORDER BY t.id DESC
但如果没有找到任务,这将返回null。