大家在查询数据库的时候肯定会有这种情况
$model;
if(!empty($name))
{
$model->andWhere(['name'=>$name]);
}
if($empty($age))
{
$model->andWhere(['age'=>$age]);
}
现在有了andFilterWhere,可以自动的帮你把空的条件过滤掉
$model->andFilterWhere(['name'=>$name]);
$model->andFilterWhere(['age'=>$age]);
转载于:https://blog.51cto.com/hfreeze/1783816