andFilterCompare() public method (available since version 2.0.5)
Helper method for easy querying on values containing some common operators.
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\yii\mongodb\Collection::buildCondition().
public $this andFilterCompare ( $name, $value, $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 |
return | $this |
The query object itself. |
Please login to continue.