Skip to content

Commit

Permalink
fix findby to and from dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnilya committed Sep 5, 2016
1 parent 676b030 commit 9b5bd80
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/Provider/DoctrineProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function getById($id)

public function findBy($contains = null, $from = null, $to = null)
{

$qb = $this->repository->createQueryBuilder('p');
$qb->select('p');
$qb->where('p.queue = :queue');
Expand All @@ -232,17 +232,16 @@ public function findBy($contains = null, $from = null, $to = null)
$qb->setParameter('contains', '%'.$contains.'%');
}

if ($from) {
$qb->andWhere('p.created > :from');
$qb->setParameter('from', '%'.$from.'%');
if ($from !== null) {
$qb->andWhere('p.created >= :from');
$qb->setParameter('from', $from);
}

if ($to) {
$qb->andWhere('p.created < :to');
$qb->setParameter('to', '%'.$to.'%');
if ($to !== null) {
$qb->andWhere('p.created <= :to');
$qb->setParameter('to', $to);
}

return $qb->getQuery();
}

}

0 comments on commit 9b5bd80

Please sign in to comment.