0
이 sql 쿼리를 심포니 쿼리 빌더 구문에 어떻게 작성할 수 있습니까?doctrine query builder를 사용하여이 sql 쿼리를 작성하는 방법은 무엇입니까?
는 분석, 지역, 자연과 정원은 내가 이런 식으로 시도 엔티티
SELECT * FROM `analysis`
INNER JOIN sample ON sample.id = analysis.sample_id
INNER JOIN region ON sample.region_id = region.id
INNER JOIN nature ON sample.nature_id = nature.id
INNER JOIN garden ON sample.garden_id = garden.id
WHERE sample.stateProduct = 'Origin'
AND analysis.status = '0'
AND region.name = 'Jangsu'
AND garden.name = 'North Tukvar'
AND nature.name = 'Thé Vert'
AND sample.sampleBio = '1'
AND sample.supplierCountry = 'Inde'
하지만, 나는 오류 MSG가없는,하지만 SQL 쿼리와 동일한 결과이 아니다.
public function countAnalysisByCriteria($stateProduct, $status, Nature $nature, Region $region, Garden $garden, $supplierName, $bio, $country, $startDate, $endDate){
$qb = $this->createQueryBuilder('analysis')
->addSelect('count(analysis) as result')
->innerJoin('analysis.sample', 'sample', 'WITH', 'analysis.sample = sample')
->innerJoin('sample.nature', 'nature', 'WITH', 'sample.nature = :nature')
->innerJoin('sample.region', 'region', 'WITH', 'sample.region = :region')
->innerJoin('sample.garden', 'garden', 'WITH', 'sample.garden = :garden')
->groupBy('result');
->andWhere('sample.stateProduct = :stateProduct');
->setParameter('stateProduct', $stateProduct);
->andWhere('sample.nature = :nature');
->setParameter('nature', $nature);
->andWhere('sample.region = :region');
->setParameter('region', $region);
->andWhere('sample.garden = :garden');
->setParameter('garden', $garden);
->andWhere('sample.dateReception BETWEEN :startDate AND :endDate');
$qb->setParameter('startDate', $startDate);
$qb->setParameter('endDate', $endDate);
}
return $qb->getQuery()->getArrayResult();
ReynierPM의 조언을 보내 주셔서 감사합니다. innerjoin에 대한 나의 실수 : "nature.id"대신 ": nature" – YornLetard
환영합니다. 기꺼이 도와주세요! – ReynierPM