zoukankan      html  css  js  c++  java
  • tp5模糊查询,分页加分页后数据处理

     public function search ()
        {
            // if(request()->isPost()){
                //获取输入的类别
                $where=[];
                $where1=[];
                $sousuo=input('sousuo');
                // var_dump($sousuo);
                $where['name']=['like',"%$sousuo"];
                $where1['name']=['like',"$sousuo%"];
                $sql=db('goodstype')->where($where)->whereOr($where1)->column('id');
                // var_dump($sql);
                //根据类别查商品
                if($sql){
                    $isok=db('goodsadd')->where('tid','in',$sql)->order('id desc')->paginate(12, false, ['query' => ['sousuo' => $sousuo]])->each(function($items,$key){
                        $items['imgs'] = explode(',',$items['imgs']); //用逗号把字符转换为数组
                        return $items;
                    });
                    // var_dump($isok);
                    $this->assign('isok',$isok);
                }else{
                    //查询商品名称
                    $where=[];
                    $where1=[];
                    $where['title']=['like',"%$sousuo"];
                    $where1['title']=['like',"$sousuo%"];
                    $where['shorttitle']=['like',"%$sousuo"];
                    $where1['shorttitle']=['like',"$sousuo%"];
                    $isok=db('goodsadd')->where($where)->whereOr($where1)->order('id desc')->paginate(12, false, ['query' => ['sousuo' => $sousuo]])->each(function($items,$key){
                        $items['imgs'] = explode(',',$items['imgs']);
                        return $items;
                    });;
                    // var_dump($isok);
                    $this->assign('isok',$isok);
                    
                    
                }
                $aa=$isok->render();
                $this->assign('aa',$aa);
                $this->assign('sousuo',$sousuo);


            // }
  • 相关阅读:
    关于前端框架讨论的链接
    和BEM的战斗:10个常见问题及如何避免
    BEM —— 源自Yandex的CSS 命名方法论
    JavaScript 语句后应该加分号么?
    彻底搞懂word-break、word-wrap、white-space
    ios UIImageWriteToSavedPhotosAlbum报错 NSPhotoLibraryAddUsageDescription
    Emmet使用手册
    vue-cli入门之项目结构分析
    ios移动端原生滚动条滚动不灵敏问题
    ios点击事件失效
  • 原文地址:https://www.cnblogs.com/sheep-fu/p/13491529.html
Copyright © 2011-2022 走看看