db\QueryTrait filterWhere()

filterWhere() public method

Sets the WHERE part of the query but ignores empty operands.

This method is similar to where(). The main difference is that this method will remove empty query operands. As a result, this method is best suited for building query conditions based on filter values entered by users.

The following code shows the difference between this method and where():

// WHERE `age`=:age
$query->filterWhere(['name' => null, 'age' => 20]);
// WHERE `age`=:age
$query->where(['age' => 20]);
// WHERE `name` IS NULL AND `age`=:age
$query->where(['name' => null, 'age' => 20]);

Note that unlike where(), you cannot pass binding parameters to this method.

See also:

public $this filterWhere ( array $condition )
$condition array

The conditions that should be put in the WHERE part. See where() on how to specify this parameter.

return $this

The query object itself

doc_Yii
2016-10-30 16:59:31
Comments
Leave a Comment

Please login to continue.