码迷,mamicode.com
首页 > Web开发 > 详细

iwebshop框架中后台筛选功能的思路整理

时间:2017-04-14 10:47:41      阅读:674      评论:0      收藏:0      [点我收藏+]

标签:iwebshop开发


本人在实际开发中,根据产品经理需求,在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;
      }
   }
}


iwebshop框架中后台筛选功能的思路整理

标签:iwebshop开发

原文地址:http://kangjunfei.blog.51cto.com/11556647/1915613

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!