调用未定义的方法Doctrine\ORM\QueryBuilder::limit()
我已经搜索了相关查询,但没有得到结果
public function getAllCTCCompensationData($ouCode,$langCode)
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('ppp.payperiodSdesc, ppesa.grossPay, pptpp.pfEmployerContribution, pptpp.esiEmployerContribution, pplw.employercontribution')
->from(PyProcessEmpStatusApproved::class, 'ppesa')
->leftJoin(PyProcessTdsPfPt::class, 'pptpp', 'with', 'ppesa.ouCode = pptpp.ouCode')
->leftJoin(PyPayGroup::class, 'ppg', 'with', 'pptpp.pgCode = ppg.pgCode')
->leftJoin(PyProcessLabourWelfare::class, 'pplw', 'with', 'ppg.pgCode = pplw.pgCode')
->leftJoin(PyPayPeriod::class,'ppp','with','pplw.payperiodCode = ppp.payperiodCode')
->leftJoin(PyPayrollCalendar::class, 'ppc', 'with', 'ppp.paycalCode = ppc.paycalCode')
->where('ppesa.ouCode = ?1')
->andWhere('ppesa.langCode = ?2')
->setParameter('1','ouCode')
->setParameter('2','langCode')
->where('ppesa.ouCode','DESC')
->limit(20);
$compData = $queryBuilder->getQuery()->getResult();
return $compData;
我想在查询中应用限制条件。如何将限制应用于查询?
为什么说未定义的方法限制?
答案 0 :(得分:0)
在orderBy
之前使用limit
,我想这是错误的消息。
public function getAllCTCCompensationData($ouCode,$langCode)
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('ppp.payperiodSdesc, ppesa.grossPay, pptpp.pfEmployerContribution, pptpp.esiEmployerContribution, pplw.employercontribution')
->from(PyProcessEmpStatusApproved::class, 'ppesa')
->leftJoin(PyProcessTdsPfPt::class, 'pptpp', 'with', 'ppesa.ouCode = pptpp.ouCode')
->leftJoin(PyPayGroup::class, 'ppg', 'with', 'pptpp.pgCode = ppg.pgCode')
->leftJoin(PyProcessLabourWelfare::class, 'pplw', 'with', 'ppg.pgCode = pplw.pgCode')
->leftJoin(PyPayPeriod::class,'ppp','with','pplw.payperiodCode = ppp.payperiodCode')
->leftJoin(PyPayrollCalendar::class, 'ppc', 'with', 'ppp.paycalCode = ppc.paycalCode')
->where('ppesa.ouCode = ?1')
->andWhere('ppesa.langCode = ?2')
->setParameter('1','ouCode')
->setParameter('2','langCode')
->orderBy('ppesa.ouCode','DESC')
->limit(20);
$compData = $queryBuilder->getQuery()->getResult();
return $compData;
}