久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

ThinkPHP使用getlist方法實(shí)現(xiàn)數(shù)據(jù)搜索功能示例

這篇文章主要介紹了ThinkPHP使用getlist方法實(shí)現(xiàn)數(shù)據(jù)搜索功能,結(jié)合實(shí)例形式較為詳細(xì)的分析了thinkPHP基于getlist實(shí)現(xiàn)根據(jù)給定條件進(jìn)行數(shù)據(jù)的讀取、顯示等相關(guān)操作技巧,需要的朋友可以參考

本文實(shí)例講述了ThinkPHP使用getlist方法實(shí)現(xiàn)數(shù)據(jù)搜索功能。分享給大家供大家參考,具體如下:

自己在ThinkPHP之中的model之中書寫getlist方法,其實(shí)所謂的搜索功能無非就是數(shù)據(jù)庫查詢之中用到的like  %string%,或者其他的 字段名=特定值,這些sql語句拼接在and語句之中;

HTML之中:

<form action="" method="get">
    <table class="account_table" width="100%" cellpadding="0" cellspacing="0">
      <tr>
        <td style="text-align:right">訂單號(hào):</td>
        <td>
          <input id="Orderid" name="order_sn" class="inp_wid3" type="text" value="{$_GET['order_sn']}"/>
        </td>
        <td style="text-align:right">
          下單日期:
        </td>
        <td colspan="5">
          <input type="text" class="inp_wid2" id="BeginTime" name="begintime" value="{$_GET['begintime']}" />
          至
          <input type="text" class="inp_wid2" id="EndTime" name="endtime" value="{$_GET['endtime']}" />
           交易完成日期
          <input type="text" class="inp_wid2" id="txtFinishedBeginTime" name="finishbegintime" value="{$_GET['finishbegintime']}" />
          至
          <input type="text" class="inp_wid2" id="txtFinishedEndTime" name="finishendtime" value="{$_GET['finishendtime']}" />
           訂單金額:
          <input type="text" class="inp_wid2" id="txtMoneyMin" name="count_price_min" value="{$_GET['count_price_min']}"/>
          至
          <input type="text" class="inp_wid2" id="txtMoneyMax" name="count_price_max" value="{$_GET['count_price_max']}" />
        </td>
      </tr>
      <tr>
        <td style="text-align:right; width:80px">采購商名稱:</td>
        <td style="width:140px">
          <input id="SupermarketName" name="user_nick_name" class="inp_wid3" type="text" value="{$_GET['user_nick_name']}" />
        </td>
        <td style="text-align:right; width:80px">采購商賬號(hào):</td>
        <td style="width:140px">
          <input id="SupermarketZh" name="user_name" class="inp_wid3" type="text" value="{$_GET['user_name']}" />
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <input class="search_btn1" type="submit" value="搜索" id="Search" />
          </td>
      </tr>
    </table>
</form>

看到?jīng)]GET方法提交表單,這個(gè)是查詢條件填入選項(xiàng);

控制器之中:

$order_msg=$order->getList();
$this->assign('info',$order_msg);//這個(gè)獲取訂單的詳細(xì)信息

Model之中:

public function getList($pagesize=25){
     $tableName = $this->getTableName();
   $where = $tableName.'.service_id = '.$_SESSION['service_site']['service_id'];
   if(!empty($_GET['order_sn'])){//查詢訂單號(hào)
       $where.= " and $tableName.`order_sn` like '%".$_GET['order_sn']."%'";
     }
   if(!empty($_GET['count_price_min'])){//查詢訂單最小金額
       $where.= " and $tableName.count_price >=".$_GET['count_price_min']."";
     }
   if(!empty($_GET['begintime'])){//下單開始日期搜索
    $_GET['begintime']=strtotime($_GET['begintime']);//將日期轉(zhuǎn)為時(shí)間戳
    $where.= " and $tableName.add_time >=".$_GET['begintime']."";
    $_GET['begintime']=date('Y-m-d',$_GET['begintime']);//將日期轉(zhuǎn)為時(shí)間戳
   }
   if(!empty($_GET['endtime'])){//下單結(jié)束日期搜索
     $_GET['endtime']=strtotime($_GET['endtime']);//將日期轉(zhuǎn)為時(shí)間戳
    $where.= " and $tableName.add_time <=".$_GET['endtime']."";
    $_GET['endtime']=date('Y-m-d',$_GET['endtime']);//將時(shí)間戳轉(zhuǎn)換成日期,方便刷新頁面后前臺(tái)顯示
   }
   if(!empty($_GET['finishbegintime'])){//交易完成開始日期搜索
    $_GET['finishbegintime']=strtotime($_GET['finishbegintime']);//將日期轉(zhuǎn)為時(shí)間戳
    $where.= " and $tableName.ok_time >=".$_GET['finishbegintime']."";
    $_GET['finishbegintime']=date('Y-m-d',$_GET['finishbegintime']);//將日期轉(zhuǎn)為時(shí)間戳
   }
   if(!empty($_GET['finishendtime'])){//交易完成結(jié)束日期搜索
     $_GET['finishendtime']=strtotime($_GET['finishendtime']);//將日期轉(zhuǎn)為時(shí)間戳
    $where.= " and $tableName.ok_time <=".$_GET['finishendtime']."";
    $_GET['finishendtime']=date('Y-m-d',$_GET['finishendtime']);//將時(shí)間戳轉(zhuǎn)換成日期,方便刷新頁面后前臺(tái)顯示
   }
   if(!empty($_GET['send'])){//查詢已發(fā)貨預(yù)警訂單,發(fā)貨時(shí)間距離此刻超過五天
    $where.= " and $tableName.send_time < '".(time()-60*60*24*5)."'";
   }
   if(!empty($_GET['doingorder'])){//查詢處理中的訂單
    $where.= " and $tableName.status in (0,1)";
   }
   if(!empty($_GET['warningorder'])){//查詢預(yù)警的訂單:已經(jīng)付款且時(shí)間超過24小時(shí)未發(fā)貨
    $where.= " and $tableName.pay_time < '".(time()-60*60*24)."'";
   }
   if(!empty($_GET['warningorder'])){//查詢預(yù)警的訂單:已經(jīng)付款且時(shí)間超過24小時(shí)未發(fā)貨
    $where.= " and $tableName.is_pay = 1 ";
   }
   if(!empty($_GET['warningorder'])){//查詢預(yù)警的訂單:已經(jīng)付款且時(shí)間超過24小時(shí)未發(fā)貨
   $where.= " and $tableName.status in (0,1)";
   }
   if(!empty($_GET['count_price_max'])){//查詢訂單最大金額
    $where.= " and $tableName.count_price <=".$_GET['count_price_max']."";
   }
   if(!empty($_GET['user_nick_name'])){//查詢采購商名稱
    $where.= " and fab_user.nick_name like '".$_GET['user_nick_name']."%'";
   }
   if(!empty($_GET['user_name'])){//查詢采購商賬號(hào)
    $where.= " and fab_user.user_name like '".$_GET['user_name']."%'";
   }
   if(!empty($_GET['supplier_nick_name'])){//查詢供應(yīng)商商名稱
    $where.= " and fab_supplier.nick_name like '".$_GET['supplier_nick_name']."%'";
   }
   if(!empty($_GET['supplier_name'])){//查詢供應(yīng)商賬號(hào)
    $where.= " and fab_supplier.supplier_name like '".$_GET['supplier_name']."%'";
   }
   if($_GET['history'] == 1){
     $where .= " and {$tableName}.status in (2,3,4) ";
   }
   if(($_GET['pay_type'])!=""&&($_GET['pay_type'])!=-1){//查詢支付方式
    $where.= " and fab_order_info.pay_type = ".$_GET['pay_type']."";
   }
   if(($_GET['status'])!=""&&($_GET['status'])!=-1){//查詢訂單狀態(tài)
    $where.= " and fab_order_info.status = ".$_GET['status']."";
   }
     if(!empty($_GET['stime']) && !empty($_GET['etime'])){
       $stime = strtotime($_GET['stime']);
       $etime = strtotime($_GET['etime']) + 24*60*60;
       $where.= " and ($tableName.`inputtime` between '$stime' and '$etime')";
     }
     $count = $this->where($where)->count();
     $this->countNum = $count;
     $Page = new \Think\Page($count,$pagesize);
     $this->page = $Page->show();
     $limit = $Page->firstRow.','.$Page->listRows;
    $sql="select $tableName.*,fab_supplier.nick_name as supplier_nick_name,fab_user.nick_name as user_nick_name
    from ($tableName left join fab_supplier on fab_order_info.supplier_id=fab_supplier.supplier_id)
    left join fab_user on fab_order_info.user_id=fab_user.user_id where $where order by $tableName.`order_id` desc limit $limit";
    $sqls="select sum(fab_order_info.count_price) as order_price,count(fab_order_info.count_price) as order_count
    from $tableName where $where order by $tableName.`order_id` desc limit $limit";
    $this->sql_msg=$this->query($sqls);
    return $this->query($sql);//訂單詳細(xì)信息
}

【網(wǎng)站聲明】本站除付費(fèi)源碼經(jīng)過測(cè)試外,其他素材未做測(cè)試,不保證完整性,網(wǎng)站上部分源碼僅限學(xué)習(xí)交流,請(qǐng)勿用于商業(yè)用途。如損害你的權(quán)益請(qǐng)聯(lián)系客服QQ:2655101040 給予處理,謝謝支持。

相關(guān)文檔推薦

下面小編就為大家分享一篇ThinkPHP整合datatables實(shí)現(xiàn)服務(wù)端分頁的示例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
下面小編就為大家分享一篇thinkphp3.2.0 setInc方法 源碼全面解析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
這篇文章主要介紹了php數(shù)據(jù)結(jié)構(gòu)之順序鏈表與鏈?zhǔn)骄€性表,結(jié)合實(shí)例形式較為詳細(xì)的分析了php實(shí)現(xiàn)順序鏈表與鏈?zhǔn)骄€性表的各種常用操作技巧,需要的朋友可以參考下
這篇文章主要介紹了tp5(thinkPHP5)操作mongoDB數(shù)據(jù)庫的方法,結(jié)合實(shí)例形式簡單分析了mongoDB數(shù)據(jù)庫及thinkPHP5連接、查詢MongoDB數(shù)據(jù)庫的基本操作技巧,需要的朋友可以參考下
下面小編就為大家分享一篇php通過header發(fā)送自定義數(shù)據(jù)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
thinkphp官網(wǎng)在去年的時(shí)候發(fā)布了tp的顛覆版本thinkphp5,tp5確實(shí)比之前的版本好用了很多,那么下面這篇文章就來給大家介紹關(guān)于在云虛擬主機(jī)部署thinkphp5項(xiàng)目的相關(guān)資料,需要的朋友可以
主站蜘蛛池模板: 亚洲国产精品视频一区 | 欧美一级做a爰片免费视频 国产美女特级嫩嫩嫩bbb片 | 国产精品免费播放 | 精品乱子伦一区二区三区 | 欧美一区免费 | 成人在线精品 | 亚洲视频在线观看 | 国产精品视频免费观看 | 欧美日韩a | 91网站在线观看视频 | 97av视频| 国产午夜精品久久久 | 成人精品视频99在线观看免费 | 欧美日韩国产精品一区二区 | 免费看一区二区三区 | 亚洲成人精品一区 | 成人精品一区二区三区 | 国产激情视频在线免费观看 | 欧美一级欧美三级在线观看 | 精品国产一区二区三区久久狼黑人 | 毛片的网址 | 久久久区| 国产在线一区二区三区 | 做a视频在线观看 | 日韩www | 日韩精品一区二区三区中文在线 | 91久操视频 | 日韩精品一区二区三区视频播放 | 久久久人成影片一区二区三区 | 亚洲精品久久久一区二区三区 | 黄色片视频免费 | 国产欧美精品一区二区三区 | 成人精品在线视频 | 男女av| 久久婷婷av | 欧美黄视频| 一区二区三区欧美大片 | 99色视频| 欧美一级片在线播放 | 美女久久久久 | 成人毛片网 |