public function getStats($contactClientId, $type, $fromDate = null, $toDate = null)
    {
        $q = $this->createQueryBuilder('s');

        $expr = $q->expr()->andX(
            $q->expr()->eq('IDENTITY(s.contactclient)', (int) $contactClientId),
            $q->expr()->eq('s.type', ':type')
        );

        if ($fromDate) {
            $expr->add(
                $q->expr()->gte('s.dateAdded', ':fromDate')
            );
            $q->setParameter('fromDate', $fromDate);
        }
        if ($toDate) {
            $expr->add(
                $q->expr()->lte('s.dateAdded', ':toDate')
            );
            $q->setParameter('toDate', $toDate);
        }

        $q->where($expr)
            ->setParameter('type', $type);

        return $q->getQuery()->getArrayResult();
    }
public function getStats($contactClientId, $type, $fromDate = null, $toDate = null)
    {
        $q = $this->createQueryBuilder('s');

        $expr = $q->expr()->andX(
            $q->expr()->eq('IDENTITY(s.contactclient)', (int) $contactClientId),
            $q->expr()->eq('s.type', ':type')
        );

        if ($fromDate) {
            $expr->add(
                $q->expr()->gte('s.dateAdded', ':fromDate')
            );
            $q->setParameter('fromDate', $fromDate);
        }
        if ($toDate) {
            $expr->add(
                $q->expr()->lte('s.dateAdded', ':toDate')
            );
            $q->setParameter('toDate', $toDate);
        }

        $q->where($expr)
            ->setParameter('type', $type);

        return $q->getQuery()->getArrayResult();
    }
public function getStats ( $ contactClientId , $ type , $ fromDate = null , $ toDate = null ) { $ q = $ this -> createQueryBuilder ( 's' ) ; $ expr = $ q -> expr ( ) -> andX ( $ q -> expr ( ) -> eq ( 'IDENTITY(s.contactclient)' , ( int ) $ contactClientId ) , $ q -> expr ( ) -> eq ( 's.type' , ':type' ) ) ; if ( $ fromDate ) { $ expr -> add ( $ q -> expr ( ) -> gte ( 's.dateAdded' , ':fromDate' ) ) ; $ q -> setParameter ( 'fromDate' , $ fromDate ) ; } if ( $ toDate ) { $ expr -> add ( $ q -> expr ( ) -> lte ( 's.dateAdded' , ':toDate' ) ) ; $ q -> setParameter ( 'toDate' , $ toDate ) ; } $ q -> where ( $ expr ) -> setParameter ( 'type' , $ type ) ; return $ q -> getQuery ( ) -> getArrayResult ( ) ; }
Fetch the base stat data from the database.

@param      $contactClientId
@param      $type
@param null $fromDate
@param null $toDate

@return array
Fetch the base stat data from the database .