mysl查询区分大小写

在这里插入图片描述

public function handle($params)
    {

        $page  = $params['page_no'] ? : 1;
        $pagesize = 10;
        $pagebeigin = ($page-1) * $pagesize;


        $keywords = $params['search_keywords'];

        $sql = "SELECT  shop_id,seller_id,shop_name,shop_area,shop_addr,shop_descript,mobile,shop_logo,status FROM sysshop_shop  
                where  status='active' AND is_open_search = 0 AND (shop_name like binary('%$keywords%') 
                OR mobile LIKE '$keywords%') 
                 limit $pagebeigin,$pagesize
                
                ";

        $countSql = "SELECT count(*) as counts ,status FROM sysshop_shop 
                where status='active' AND is_open_search = 0 AND (shop_name like binary('%$keywords%') 
                OR mobile LIKE '$keywords%' )    ";

        $rows = app::get('base')->database()->executeQuery($sql)->fetchAll();
        $count = app::get('base')->database()->executeQuery($countSql)->fetchAll();

        foreach ($rows as $key => $value)
        {
            if($rows[$key]['shop_area'] == "null"){
                $rows[$key]['shop_area'] = NULL;
            }

            if($rows[$key]['shop_addr'] == "null"){
                $rows[$key]['shop_addr'] = NULL;
            }
        }

        $data = [
            'list'=>$rows,
            'total'=>$count[0]['counts']
        ];


        //$rows['count'] = $count[0]['counts'];
        return $data;
    }

猜你喜欢

转载自blog.csdn.net/ahaotata/article/details/84938515