我正在尝试从查询中返回一个数组结果 - 但我只是将第一行返回。
计数返回5(与查询匹配的行数) - 为了显示那些,我缺少什么?
public function getFailType($email)
{
$q = $this->getEntityManager()->getConnection()->createQueryBuilder();
$q->select('dnc.comments, count(dnc.reason) as total')
->from(MAUTIC_TABLE_PREFIX.'lead_donotcontact', 'dnc')
->where('dnc.channel_id = :channelId')
->groupBy('dnc.comments')
->setParameter('channelId', $email);
$results = $q->execute()->fetchAll();
$count = count($results);
$dnc = isset($results) ? $results[0] : null;
if ($dnc === null) {
return false;
}
return [
'count' => $count,
'total' => $dnc['total'],
'comments' => $dnc['comments'],
];
}
返回以下内容:
$printout->getFailType($objectId)['count'] = 5
$printout->getFailType($objectId)['total'] = 20
$printout->getFailType($objectId)['comments'] = Contact unsubscribed via email