你們在查詢數據庫的時候確定會有這種狀況php
$model; if(!empty($name)) { $model->andWhere(['name'=>$name]); } if($empty($age)) { $model->andWhere(['age'=>$age]); }
如今有了andFilterWhere,能夠自動的幫你把空的條件過濾掉數據庫
$model->andFilterWhere(['name'=>$name]); $model->andFilterWhere(['age'=>$age]);