本人在实际开发中,根据产品经理需求,在iwebshop框架原有的后台订单筛选功能里增加商户名称模糊筛选!
开发思路:首先要明白筛选的数据在数据库中的位置,对要筛选的字段进行模糊查询!
开发主要注意:因为iwebshop后台订单筛选功能是写在封装好的一个类下面 order/order_class.php里面,所以sql查询后的遍历和sql本身的条件,一定要注意书写正确!
实际开发书写代码思路讲解:
if(isset($search['name']) && isset($search['keywords']))
{
$name = IFilter::act($search['name'], 'string');
$keywords = IFilter::act($search['keywords'], 'string');
if ($name && $keywords)
{
switch ($name)
{
case "seller_name":
{
//执行查询订单管理商户名称
$sellerObj = new IQuery('seller');
$sellerObj->where="true_name like '%".$keywords."%'";
$sellerRow =$sellerObj->find();
$sellerArray =[];
//遍历开始
foreach ($sellerRow as $key=>$val){
$sellerArray[] = $val['id'];
}
//因为涉及到单个模糊查询和多个模糊条件
if(is_array($sellerArray)){
$where .= $sellerRow ?" and o.seller_id in (".join(',',$sellerArray).")":"and null";
}else{
$where .= $sellerRow ?" and o.seller_id = ".$sellerArray[0]:"and null";
}
}
break;
default:
$where .= " and o.".$name." = '".$keywords."'";
break;
}
}
}
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。