db\Query andFilterCompare()

andFilterCompare() public method (available since version 2.0.8)

Adds a filtering condition for a specific column and allow the user to choose a filter operator.

It adds an additional WHERE condition for the given field and determines the comparison operator based on the first few characters of the given value. The condition is added in the same way as in andFilterWhere() so empty values are ignored. The new condition and the existing one will be joined using the 'AND' operator.

The comparison operator is intelligently determined based on the first few characters in the given value. 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.
  • >: the column must be greater than the given value.
  • <=: the column must be less than or equal to the given value.
  • >=: the column must be greater than or equal to the given value.
  • <>: the column must not be the same as the given value.
  • =: the column must be equal to the given value.
  • If none of the above operators is detected, the $defaultOperator will be used.
public $this andFilterCompare ( $name, $value, $defaultOperator = '=' )
$name string

The column name.

$value string

The column value optionally prepended with the comparison operator.

$defaultOperator string

The operator to use, when no operator is given in $value. Defaults to =, performing an exact match.

return $this

The query object itself

doc_Yii
2016-10-30 16:58:55
Comments
Leave a Comment

Please login to continue.