1
나는 다음 테이블을Doctrine2
id int not null auto icrement
email_name varchar
event_type varchar
이메일 유형이 - 나는 doctrine2에서 다음과 같이 쿼리를 작성해야 가능한 값을 (전송, 공개, 탈퇴, 클릭)
SELECT COUNT(ee.id) as total, (SELECT COUNT(e.id) from email_statistic as e where e.event_type = 'open') as opened FROM email_statistic as ee
전체 금액을 선택하고 통계에 대해 열린 전자 메일의 수를 선택하고 싶습니다. 이 wia 교리는 어떻게 수행합니까?
$qb = $this->createQueryBuilder('ee')
->select('count(ee) As total');
$qb2 = $this->createQueryBuilder('e')
->select('count(e) As opened');
$qb2
->andWhere('es.eventType = :eventType')
->setParameter('eventType', 'open');
$qb->addSelect($qb2) --- this does not allowed by doctrine
NATIVE QUERY를 사용해야합니까? 나는 이것을 dql로 할 수 있습니까?
넣어> 선택은()' – mmmm
@mmmm는 – user4785882
쿼리 빌더 DQL를 통해 엔티티와 함께 작동 작동하지 않습니다. 엔티티와 관련된 엔티티가 보이지 않습니다. 그리고 당신의 추측은 정확합니다, 아마도 네이티브 질의를 여기에서 사용하기를 원할 것입니다. –