Heim  >  Artikel  >  Backend-Entwicklung  >  thinkphp实现模模糊糊匹配(学习贵哥代码)

thinkphp实现模模糊糊匹配(学习贵哥代码)

WBOY
WBOYOriginal
2016-06-13 12:36:09885Durchsuche

thinkphp实现模糊匹配(学习贵哥代码)

模板文件:



   


       
        资讯管理-{$site.SITE_INFO.name}
   
            $addCss="";
            $addJs="";
            $currentNav ='资讯管理 > 资讯列表';
       

       
       
   
   
    <script> <br> function import_check(){ <br> var f_content = form1.file.value; <br> var fileext=f_content.substring(f_content.lastIndexOf("."),f_content.length) <br> fileext=fileext.toLowerCase() <br> if (fileext!='.xlsx') <br> { <br> alert("对不起,导入数据&#26684;式必须是xlsx&#26684;式文件哦,请您调整&#26684;式后重新上传,谢谢 !"); <br> return false; <br> } <br> <span style="white-space:pre">else{ document.getElementById("form1").submit();}<br> <span style="white-space:pre"><br> } <br> </script> 
       

           
           

               
               
           

       

       

       
       
       
   


控制器:

    public function index() {
   //作为搜索条件查找某律师的信息
   $where = '1=1';
if(!empty($_GET['name'])) $where .= ' and true_name regexp \'' . trim($_GET['name']) . '\'';
if(!empty($_GET['mobile'])) $where .= ' and law_mobile regexp \'' . trim($_GET['mobile']) . '\'';
if(!empty($_GET['email'])) $where .= ' and email regexp \'' . trim($_GET['email']) . '\'';
if(!empty($_GET['sex'])) $where .= ' and sex regexp \'' . trim($_GET['sex']) . '\'';
if(!empty($_GET['st'])) $where .= ' and first_date >= \'' . substr(str_replace('+', ' ', $_GET['st']),0,4) . '\'';
if(!empty($_GET['et'])) $where .= ' and first_date         $M = M("Constant");  
        $count = $M->where($where)->count();
        import("ORG.Util.Page"); // 导入分页类
   $d = new Page($count,15);  //分页
   $list=$M->limit($d->firstRow.','.$d->listRows)->select();
   $dd=$d->show();
        $this->assign('list', D('Lawerinfo')->listMember($d->firstRow, $d->listRows, $where));
      $this->assign('page',$dd); 
        $this->display();
   }


模型层:

public function listMember($firstRow = 0, $listRows = 20, $where) {
        $M = M('Constant');

$list = $M->where($where)->limit("$firstRow , $listRows")->select();

return $list;
    }


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn