yii\mongodb\Query::andFilterCompare PHP Method

andFilterCompare() public method

The comparison operator is intelligently determined based on the first few characters in the given value and internally translated to a MongoDB operator. In particular, it recognizes the following operators if they appear as the leading characters in the given value: <: the column must be less than the given value ($lt). >: the column must be greater than the given value ($gt). <=: the column must be less than or equal to the given value ($lte). >=: the column must be greater than or equal to the given value ($gte). <>: the column must not be the same as the given value ($ne). Note that when $partialMatch is true, this would mean the value must not be a substring of the column. =: the column must be equal to the given value ($eq). none of the above: use the $defaultOperator Note that when the value is empty, no comparison expression will be added to the search condition.
See also: yii\mongodb\Collection::buildCondition()
Since: 2.0.5
public andFilterCompare ( string $name, string $value, string $defaultOperator = '=' )
$name string column name
$value string column value
$defaultOperator string Defaults to =, performing an exact match. For example: use 'LIKE' or 'REGEX' for partial cq regex matching
    public function andFilterCompare($name, $value, $defaultOperator = '=')
    {
        $matches = [];
        if (preg_match('/^(<>|>=|>|<=|<|=)/', $value, $matches)) {
            $op = $matches[1];
            $value = substr($value, strlen($op));
        } else {
            $op = $defaultOperator;
        }
        return $this->andFilterWhere([$op, $name, $value]);
    }