zoukankan      html  css  js  c++  java
  • 多条件搜索(基础)

         根据要搜索的接收的数据 接收到后 对要搜索的进行拼接

      列如以下:

      public function searchby(){

       //接收到数据
            $admin_name    = trim(I("get.admin_name"));
            $email        = trim(I("get.email"));
            $phone         = trim(I("get.phone"));
            $status        = trim(I("get.status"));

       //判断
            if (!empty($admin_name) && isset($admin_name) && $admin_name!='0' ) {
                
                $where = " admin_name like '%$admin_name%'";

            }

        //判断

            if ( !empty($email) && isset($email) && $email!='0') {

                if ( !empty($admin_name) && isset($admin_name) && $admin_name!='0') {
                    
                    $where .= " AND email = '$email'";

                }else{

                    $where .= " email = '$email'";

                }

            }

        //判断


            if ( !empty($phone) && isset($phone) && $phone!='0' ) {

                if ( !empty($admin_name) && isset($admin_name) && $admin_name!='0') {

                    $where .= " AND phone = '$phone' ";

                }else{

                    if ( !empty($email) && isset($email) && $email!='0') {

                        $where .= " AND phone = '$phone' ";

                    }else{

                        $where = "phone = '$phone' ";

                    }
                }
            }

        //判断


            if ( !empty($status) && isset($status) && $status!='0' ) {

                if ( !empty($admin_name) && isset($admin_name) && $admin_name!='0') {

                    $where .= " AND status = '$status' ";

                }else{

                    if ( !empty($email) && isset($email) && $email!='0') {

                        $where .= " AND status = '$status' ";

                    }else{

                        if ( !empty($phone) && isset($phone) && $phone!='0' ) {
        
                            $where .= " AND status = '$status' ";

                        }else{
        
                            $where = " status = '$status' ";

                        }                   

                    }
                }
            }

       //echo $where;exit;

            return $this
                ->table()
                ->join('user ON user.u_id = arrearge.u_id ')
                ->join('money_type ON money_type.m_t_id = arrearge.m_t_id')
                ->where($where)
                ->select();        

        }

  • 相关阅读:
    bzoj 2002: [Hnoi2010]Bounce 弹飞绵羊(分块算法)
    hdu 3652 "B-number"(数位DP)
    数位DP+其他
    hdu 4352 "XHXJ's LIS"(数位DP+状压DP+LIS)
    CodeForces 55D "Beautiful numbers"(数位DP+离散化处理)
    洛谷 P1163"银行贷款"(二分)
    ZOJ-3872-Beauty of Array-思维
    洛谷P3951 小凯的疑惑
    CodeForces
    CodeForces
  • 原文地址:https://www.cnblogs.com/laowenBlog/p/5391294.html
Copyright © 2011-2022 走看看