示例#1
0
 public function visitCollectionComparisonExpression(Expr\CollectionComparisonExpression $comparison)
 {
     $field = $expr->getField();
     $value = (array) $this->visitValueIdentifier($comparison->getValue());
     switch ($comparison->getOperator()) {
         case Expr\CollectionComparisonExpression::IN:
             return $field . Literals::L_COLON . Literals::L_IN . Literals::L_COLON . Literals::L_BRANCKET_OPEN . implode(Literals::L_COMMA, $value) . Literals::L_BRANCKET_CLOSE;
         case Expr\CollectionComparisonExpression::NOT_IN:
             return $field . Literals::L_COLON . Literals::L_NOT_IN . Literals::L_COLON . Literals::L_BRANCKET_OPEN . implode(Literals::L_COMMA, $value) . Literals::L_BRANCKET_CLOSE;
         default:
             throw new \RuntimeException();
     }
 }
示例#2
0
 public function visitCollectionComparisonExpression(Expr\CollectionComparisonExpression $comparison)
 {
     // fixme
     $rawValue = $this->visitValueIdentifier($comparison->getValue());
     $parameterName = str_replace('.', '_', $comparison->getField()) . '_' . substr(md5(json_encode($rawValue)), 0, 5);
     $parameter = new Parameter($parameterName, $rawValue);
     $placeHolder = ':' . $parameterName;
     $qb = $this->getQueryBuilder();
     switch ($comparison->getOperator()) {
         case Expr\CollectionComparisonExpression::IN:
             $qb->getParameters()->add($parameter);
             return $qb->expr()->in($this->visitField($comparison->getField()), $placeHolder);
         case Expr\CollectionComparisonExpression::NOT_IN:
             $qb->getParameters()->add($parameter);
             return $qb->expr()->notIn($this->visitField($comparison->getField()), $placeHolder);
         default:
             throw new \RuntimeException();
     }
 }