0
我正在研究基於Symfony2的PHP項目,我希望下面的這個教程能夠在Symfony2上工作,但實際上我通過使用「... FROM xx JOIN(SELECT .... 「:Symfony2 - 學說 - 從SQL到DQL
[Semantical Error] line 0, col 176 near '(
SELECT': Error: Class '(' is not defined.
,我想使工作的最後DQL語句是:
return $this->getEntityManager()
->createQuery(
"SELECT u.username, m1.id, n.id as notification, n.vue, u.lastActivity, LEFT(m1.message,60) as Message, m1.lu, m1.dateEnvoi, i.image
FROM MCoreBundle:Messages m1
JOIN (
SELECT m.from, max(dateEnvoi) as dateEnvoi
FROM MCoreBundle:Messages m
JOIN MCoreBundle:User u on m.from = u.id
WHERE m.to = :user
GROUP BY m.from
) t ON m1.from = t.from AND
m1.dateEnvoi = t.dateEnvoi,
MCoreBundle:User u,
MCoreBundle:Notification n,
MCoreBundle:Images i WHERE
u.id = m.from AND
n.id = m.notification AND
i.user = u.id")
->setParameters(array('user' => $iIDUser))
->getResult();
實際的問題: 主義/ Symfony的犯規recorgnize的」 ... FROM XX加入(選擇....「
你加入MCoreBundle:用戶U,MCoreBundle:通知N,MCoreBundle:圖片我。如果是的話,你必須在每次加入表格時寫入加入。 – sonam
嘗試過,但它並沒有真正解決我的問題,仍然得到相同的錯誤...'(SELECT':錯誤:類'('未定義。 –