Пример #1
0
 public function testGetSetHasRegistrationDate()
 {
     $this->assertFalse($this->criteria->hasRegistrationDate());
     $this->criteria->setRegistrationDate('1978-02-17');
     $this->assertTrue($this->criteria->hasRegistrationDate());
     $this->assertEquals('1978-02-17', $this->criteria->getRegistrationDate());
 }
Пример #2
0
 /**
  * @param UserCriteria $criteria
  * @return array
  */
 public function findByCriteria(UserCriteria $criteria)
 {
     $qb = $this->createQueryBuilder('u');
     if ($criteria->hasId()) {
         $qb->where('u.id = :id');
         $qb->setParameter('id', $criteria->getId());
         $criteria->setLimit(1);
     }
     if ($criteria->hasEmail()) {
         $qb->where('u.email = :email');
         $qb->setParameter('email', $criteria->getEmail());
         $criteria->setLimit(1);
     }
     if ($criteria->hasState()) {
         $qb->andWhere('u.state = :state');
         $qb->setParameter('state', $criteria->getState());
     }
     if ($criteria->hasRegistrationDate()) {
         $qb->andWhere('u.registrationDate = :regdate');
         $qb->setParameter('regdate', $criteria->getRegistrationDate());
     }
     if ($criteria->hasLastLoginDate()) {
         $qb->andWhere('u.lastLoginDate = :lastlogin');
         $qb->setParameter('lastlogin', $criteria->getLastLoginDate());
     }
     $criteria->hasOrder() ? $qb->addOrderBy('u.' . $criteria->getOrder(), $criteria->getOrderDirection()) : null;
     $criteria->hasLimit() ? $qb->setMaxResults($criteria->getLimit()) : null;
     $criteria->hasOffset() ? $qb->setFirstResult($criteria->getOffset()) : null;
     $query = $qb->getQuery();
     return $query->getResult();
 }