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

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

Matches if the property named $propertyName is like the $operand, using standard SQL wildcards.
public like ( string $propertyName, string $operand, boolean $caseSensitive = true ) : object
$propertyName string The name of the property to compare against
$operand string The value to compare with
$caseSensitive boolean Whether the matching should be done case-sensitive
Результат object
    public function like($propertyName, $operand, $caseSensitive = true)
    {
        $aliasedPropertyName = $this->getPropertyNameWithAlias($propertyName);
        if ($caseSensitive === true) {
            return $this->queryBuilder->expr()->like($aliasedPropertyName, $this->getParamNeedle($operand));
        }
        return $this->queryBuilder->expr()->like($this->queryBuilder->expr()->lower($aliasedPropertyName), $this->getParamNeedle(UnicodeFunctions::strtolower($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;
 }