0
$messageQuery
->select('m, COUNT(pm) AS newResponses')
//->addSelect($messageQuery->expr()->countDistinct('pm.id'))
->from('entities:PrivateMessage', 'm')
->where('m.employeeId = :employeeId AND m.responseTo = 0')
->innerJoin('entity:PrivateMessage', 'pm', 'WITH', 'pm.responseTo = m.id AND pm.employeeRead = 0')
->setParameter('employeeId', $employeeId)
->setFirstResult($offset)
->setMaxResults($max)
->addGroupBy('m.id')
->orderBy('m.id', 'DESC');
假設有兩條消息,其中employeeId =另一個沒有。我期望從這個查詢得到的結果是兩個數組,其中實體對象爲索引0,計數爲索引numResponses(第一行爲2,第二行爲0)。我得到的是$ messageQuery-> getQuery() - > getResult();上的空數組。Doctrine2在返回空數組的同一個表上的加入計數
沒有人有任何想法,爲什麼這可能是這樣嗎?有什麼明顯的我在這裏失蹤?