调用未定义的方法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;
我想在查询中应用限制条件。如何将限制应用于查询?
供参考,请使用此链接https://www.doctrine-project.org/projects/doctrine1/en/latest/manual/dql-doctrine-query-language.html#limit-and-offset-clauses
为什么说未定义方法限制?
最佳答案
在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;
}