Yii2 - andFilterWhere

filterWhere() - ignores search by empty values.
When the search is executed by two fields, for example book and author, if the book value is empty then filterWhere() ignores the search by book and the search will be executed only by author

filterWhere()
    
    $query->filterWhere([
    	'author' => $author,
    	'book' => null,
	]);
    // generated sql query
    // SELECT * FROM `library` WHERE (`author` = $author)
    
andFilterWhere - Appends WHERE condition to the existing one.
    
    $query->where(['author' => $author]);
    $query->andFilterWhere(['book' => $book]);
    // generated sql query
    // SELECT * FROM `library` WHERE (`author` = $author) AND (`book` = $book)
    

Comments