1. 程式人生 > >支援手機尾號搜尋的條件

支援手機尾號搜尋的條件

新增使用者登入賬號條件(支援尾號搜尋)

        $sql  ="select group_concat(id) from `user` where `user_name` like '%".trim($user_name)."%'";           
        $ids = $GLOBALS['db']->getOne($sql);
        if($ids)
            $conditon .= " and  uid in ($ids) ";
        else
            $conditon .= " and  uid >0 ";
        $res = db('database')->where($condition)->select();

思路:用trim函式去掉搜尋關鍵字兩邊的空格、換行符等,再用模糊搜尋。