Knp\Bundle\KnpBundlesBundle\Repository\BundleRepository::getEvolutionCounts PHP Method

getEvolutionCounts() public method

public getEvolutionCounts ( $period = 50 )
    public function getEvolutionCounts($period = 50)
    {
        $rsm = new ResultSetMapping();
        $rsm->addEntityResult('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Score', 'e');
        $rsm->addFieldResult('e', 'id', 'id');
        $rsm->addFieldResult('e', 'date', 'date');
        $rsm->addFieldResult('e', 'value', 'value');
        $sql = <<<EOF
SELECT id, COUNT(id) as `value`, DATE(createdAt) as `date`
FROM bundle
WHERE createdAt > :period
GROUP BY `date`
ORDER BY `date` ASC
EOF;
        $periodDate = new \DateTime(sprintf('%d days ago', $period));
        $periodDate = $periodDate->format('Y-m-d H:i:s');
        return $this->getEntityManager()->createNativeQuery($sql, $rsm)->setParameter('period', $periodDate)->getResult();
    }