src/Utility/Search.php
protected function getWhereCondition(string $field, array $criteria): array
    {
        $value = is_array($criteria['value']) ? $criteria['value'] : trim($criteria['value']);

        if ('' === $value) {
            return $this->getEmptyWhereCondition($field, $criteria);
        }

        $value = $this->handleMagicValue($value);
        $operator = $this->searchFields[$field]['operators'][$criteria['operator']];

        if (isset($operator['pattern'])) {
            $pattern = $operator['pattern'];
            $value = str_replace('{{value}}', $value, $pattern);
        }

        $type = 'string';
        if (! empty($this->searchFields[$field]['type']) &&
            array_key_exists($this->searchFields[$field]['type'], (array)Type::getMap())
        ) {
            $type = $this->searchFields[$field]['type'];
        }

        if (in_array($operator['operator'], ['IN', 'NOT IN'])) {
            $type .= '[]';
            $value = (array)$value;
        }

        if ($operator['operator'] === 'NOT IN') {
            return [ 'OR' => [ $field . ' IS NULL', new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ]];
        }

        return [ new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ];
    }
protected function getWhereCondition(string $field, array $criteria): array
    {
        $value = is_array($criteria['value']) ? $criteria['value'] : trim($criteria['value']);

        if ('' === $value) {
            return $this->getEmptyWhereCondition($field, $criteria);
        }

        $value = $this->handleMagicValue($value);
        $operator = $this->searchFields[$field]['operators'][$criteria['operator']];

        if (isset($operator['pattern'])) {
            $pattern = $operator['pattern'];
            $value = str_replace('{{value}}', $value, $pattern);
        }

        $type = 'string';
        if (! empty($this->searchFields[$field]['type']) &&
            array_key_exists($this->searchFields[$field]['type'], (array)Type::getMap())
        ) {
            $type = $this->searchFields[$field]['type'];
        }

        if (in_array($operator['operator'], ['IN', 'NOT IN'])) {
            $type .= '[]';
            $value = (array)$value;
        }

        if ($operator['operator'] === 'NOT IN') {
            return [ 'OR' => [ $field . ' IS NULL', new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ]];
        }

        return [ new Comparison(new IdentifierExpression($field), $value, $type, $operator['operator']) ];
    }
protected function getWhereCondition ( string $ field , array $ criteria ) : array { $ value = is_array ( $ criteria [ 'value' ] ) ? $ criteria [ 'value' ] : trim ( $ criteria [ 'value' ] ) ; if ( '' === $ value ) { return $ this -> getEmptyWhereCondition ( $ field , $ criteria ) ; } $ value = $ this -> handleMagicValue ( $ value ) ; $ operator = $ this -> searchFields [ $ field ] [ 'operators' ] [ $ criteria [ 'operator' ] ] ; if ( isset ( $ operator [ 'pattern' ] ) ) { $ pattern = $ operator [ 'pattern' ] ; $ value = str_replace ( '{{value}}' , $ value , $ pattern ) ; } $ type = 'string' ; if ( ! empty ( $ this -> searchFields [ $ field ] [ 'type' ] ) && array_key_exists ( $ this -> searchFields [ $ field ] [ 'type' ] , ( array ) Type :: getMap ( ) ) ) { $ type = $ this -> searchFields [ $ field ] [ 'type' ] ; } if ( in_array ( $ operator [ 'operator' ] , [ 'IN' , 'NOT IN' ] ) ) { $ type .= '[]' ; $ value = ( array ) $ value ; } if ( $ operator [ 'operator' ] === 'NOT IN' ) { return [ 'OR' => [ $ field . ' IS NULL' , new Comparison ( new IdentifierExpression ( $ field ) , $ value , $ type , $ operator [ 'operator' ] ) ] ] ; } return [ new Comparison ( new IdentifierExpression ( $ field ) , $ value , $ type , $ operator [ 'operator' ] ) ] ; }
Prepare and return where statement condition.

@param string $field Field name
@param mixed[] $criteria Criteria properties
@return mixed[]
Prepare and return where statement condition .