昨天写了一个多条件模糊查询及分页的方法记录一下
我的查询方法写在了service层
这是think_cmf 5.1版本的代码 5.0的在下面 (5.1的能不能再5.0里面用,目前没做实现)
/**
* 模糊查询及分页
* @param string $name 查询字段值
* @return listHezuoShe 返回查询数据
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function index($name='')
{
//初始化数据库对象
$hezuoshe = new HezuosheModel();
//这里的where[]写的是条件,你要查询的字段
$where['h_company_name|h_legal_representative|h_region_of_shi|h_region_of_xian|h_type|h_company_address|h_business_scope|h_industry|h_key_personne'] = ['like',