Neos\Flow\Persistence\Doctrine\Query::in PHP Метод

in() публичный Метод

Returns an "in" criterion used for matching objects against a query. It matches if the property's value is contained in the multivalued operand.
public in ( string $propertyName, mixed $operand ) : object
$propertyName string The name of the property to compare against
$operand mixed The value to compare with, multivalued
Результат object
    public function in($propertyName, $operand)
    {
        // Take care: In cannot be needled at the moment! DQL escapes it, but only as literals, making caching a bit harder.
        // This is a todo for Doctrine 2.1
        return $this->queryBuilder->expr()->in($this->getPropertyNameWithAlias($propertyName), $operand);
    }

Usage Example

 /**
  * @param ClassMetadata $targetEntity
  * @param string $targetEntityPropertyName
  * @return Query
  */
 protected function getSubselectQuery(ClassMetadata $targetEntity, $targetEntityPropertyName)
 {
     $subselectQuery = new Query($targetEntity->getAssociationTargetClass($targetEntityPropertyName));
     $propertyName = str_replace($targetEntityPropertyName . '.', '', $this->path);
     switch ($this->operator) {
         case '==':
             $subselectConstraint = $subselectQuery->equals($propertyName, $this->operand);
             break;
         case '!=':
             $subselectConstraint = $subselectQuery->logicalNot($subselectQuery->equals($propertyName, $this->operand));
             break;
         case '<':
             $subselectConstraint = $subselectQuery->lessThan($propertyName, $this->operand);
             break;
         case '>':
             $subselectConstraint = $subselectQuery->greaterThan($propertyName, $this->operand);
             break;
         case '<=':
             $subselectConstraint = $subselectQuery->lessThanOrEqual($propertyName, $this->operand);
             break;
         case '>=':
             $subselectConstraint = $subselectQuery->greaterThanOrEqual($propertyName, $this->operand);
             break;
         case 'like':
             $subselectConstraint = $subselectQuery->like($propertyName, $this->operand);
             break;
         case 'in':
             $subselectConstraint = $subselectQuery->in($propertyName, $this->operand);
             break;
     }
     $subselectQuery->matching($subselectConstraint);
     return $subselectQuery;
 }