1.在模型中定义搜索器
```
//搜索器:格式search+字段名+Attr
public function searchExamnameAttr($query, $value, $data){
$query->where('examname','like', '%'. $value . '%');
}
```
```
2.在控制器中使用
//没有有搜索条件时
if($val == ''){
$userinfo = ExamModel::limit($start,$limit)->order('create_time','desc')->select();
$count = count(ExamModel::select());
}else{
//有搜索条件时:withSearch
$userinfo = ExamModel::withSearch(['examname'],['examname'=>$val])->limit($start,$limit)->order('create_time','desc')->select();
$count = count(ExamModel::withSearch(['examname'],['examname'=>$val])->select());
}
```