I am trying to figure out how to count instalments attached to the contract and then return it in the result if there are less than 2.
->select('cc') ->addSelect('COUNT(cci) AS HIDDEN numberOfInstalments') ->from('AppBundle:ClientContract', 'cc') ->innerJoin('AppBundle:ClientContractInstalment', 'cci', 'WITH', 'cci.clientContract = cc') ->andHaving('numberOfInstalments < :numberOfRequiredInstalments'( ->setParameter('numberOfRequiredInstalments', 2) ->getResult()
The code from above works well when I add one
ClientContract, but the problem gets when I add more client contracts, then
COUNT(cci) counts all instalments instead of per
How can I change this, so
COUNT(cci) will count instalments inside the ClientContract and if less than 2, return in the result?
Source: Symfony Questions
Was this helpful?
0 / 0