yii\mongodb\QueryBuilder::buildBetweenCondition PHP 메소드

buildBetweenCondition() 공개 메소드

Creates an Mongo condition, which emulates the BETWEEN operator.
public buildBetweenCondition ( string $operator, array $operands ) : array
$operator string the operator to use
$operands array the first operand is the column name. The second and third operands describe the interval that column value should be in.
리턴 array the generated Mongo condition.
    public function buildBetweenCondition($operator, $operands)
    {
        if (!isset($operands[0], $operands[1], $operands[2])) {
            throw new InvalidParamException("Operator '{$operator}' requires three operands.");
        }
        list($column, $value1, $value2) = $operands;
        if (strncmp('NOT', $operator, 3) === 0) {
            return [$column => ['$lt' => $value1, '$gt' => $value2]];
        } else {
            return [$column => ['$gte' => $value1, '$lte' => $value2]];
        }
    }