public function assembleBetweenPredicate(BetweenPredicate $predicate)
 {
     $start = $this->_assemblePrepared($predicate->getRangeStart()) ?: $this->assembleSegment($predicate->getRangeStart());
     $end = $this->_assemblePrepared($predicate->getRangeEnd()) ?: $this->assembleSegment($predicate->getRangeEnd());
     $not = $predicate instanceof NotBetweenPredicate ? ' NOT' : '';
     return $this->assembleSegment($predicate->getField()) . $not . ' BETWEEN ' . $start . ' AND ' . $end;
 }
 public function testGettersAndSetters()
 {
     $predicate = new BetweenPredicate();
     $predicate->setValues((new NumericExpression())->setValue(1), (new NumericExpression())->setValue(5));
     $this->assertEquals([(new NumericExpression())->setValue(1), (new NumericExpression())->setValue(5)], $predicate->getRangeValues());
     $this->assertEquals((new NumericExpression())->setValue(1), $predicate->getRangeStart());
     $this->assertEquals((new NumericExpression())->setValue(5), $predicate->getRangeEnd());
     $predicate->setField('test');
     $this->assertEquals(FieldExpression::create('test'), $predicate->getField());
 }
Beispiel #3
0
 public function assembleBetween(BetweenPredicate $betweenPredicate)
 {
     $gte = new GreaterThanOrEqualPredicate();
     $gte->setField($betweenPredicate->getField());
     $lte = new LessThanOrEqualPredicate();
     $lte->setField($betweenPredicate->getField());
     $set = new PredicateSet();
     if ($betweenPredicate instanceof NotBetweenPredicate) {
         $gte->setExpression($betweenPredicate->getRangeEnd());
         $lte->setExpression($betweenPredicate->getRangeStart());
         $set->addPredicate($lte);
         $set->addPredicate($gte);
     } else {
         $gte->setExpression($betweenPredicate->getRangeStart());
         $lte->setExpression($betweenPredicate->getRangeEnd());
         $set->addPredicate($gte);
         $set->addPredicate($lte);
     }
     return $this->assembleSegment($set);
 }