我正在使用codeignater,但我的数据表搜索框不起作用

时间:2019-06-29 12:46:57

标签: jquery mysql sql ajax codeigniter

当我在数据表的搜索框中键入内容时,它会给我

DataTables warning: table id=bilty_table 

以下是我要在数据表搜索框中使用的模型代码

function __construct() {

        $this->table = 'bilty b';
        $this->column_order = array(null, 'b.id','b.lr_no','user.user_full_name as consignor','b.consignor_gst_no','user1.user_full_name as consignee','b.consignee_gst_no','st.user_full_name as supply','b.supplay_gst_no','ss.user_full_name as bill','b.bill_gst','b.no_of_pkgs','mm.packaging_name as material','b.lr_description','b.rate_on','b.lr_actual_weight','b.lr_charge_of_weight','b.lr_invoice_no','b.lr_eway_bill_no','b.lr_invoice_amount','b.lr_invoice_date','b.delivary_at','b.lr_date','bk.branch_name as bookat','bn.branch_name as from','bn1.branch_name as to','b.lr_pay_mode','b.mode_of_payment','b.text_cheque','bb.bank_name as bankn','b.select_billed','b.select_due','b.lr_freight','b.cartage','b.lr_hammali','b.lr_st_charge','b.lr_collection_charge','b.lr_door_delivery','b.lr_insurance','b.lr_total','b.lr_gst','b.lr_grand_total','mm.packaging_name as material');

        $this->column_search = array('b.id','b.lr_no','user.user_full_name as consignor','b.consignor_gst_no','user1.user_full_name as consignee','b.consignee_gst_no','st.user_full_name as supply','b.supplay_gst_no','ss.user_full_name as bill','b.bill_gst','b.no_of_pkgs','mm.packaging_name as material','b.lr_description','b.rate_on','b.lr_actual_weight','b.lr_charge_of_weight','b.lr_invoice_no','b.lr_eway_bill_no','b.lr_invoice_amount','b.lr_invoice_date','b.delivary_at','b.lr_date','bk.branch_name as bookat','bn.branch_name as from','bn1.branch_name as to','b.lr_pay_mode','b.mode_of_payment','b.text_cheque','bb.bank_name as bankn','b.select_billed','b.select_due','b.lr_freight','b.cartage','b.lr_hammali','b.lr_st_charge','b.lr_collection_charge','b.lr_door_delivery','b.lr_insurance','b.lr_total','b.lr_gst','b.lr_grand_total','mm.packaging_name as material');
        $this->order = array('b.id' => 'asc');
    }



    public function getRows($postData){
        $this->_get_datatables_query($postData);
        $this->db->select('b.cartage,b.bank,b.select_billed,b.select_due,b.booking_at,b.supplay_to_name,b.supplay_gst_no,b.text_cheque,b.mode_of_payment,b.rate_on,b.id,b.consignor_name,b.consignor_gst_no,b.consignee_name,b.consignee_gst_no,b.bill_party,b.bill_gst,b.no_of_pkgs,b.pkg_code,b.lr_description,b.lr_actual_weight,b.lr_charge_of_weight,b.lr_invoice_no,b.lr_eway_bill_no,b.lr_invoice_amount,b.lr_invoice_date,b.delivary_at,b.lr_no,lr_date,b.lr_from,b.lr_to,b.lr_pay_mode,b.lr_freight,b.lr_hammali,b.lr_st_charge,b.lr_collection_charge,b.lr_door_delivery,b.lr_insurance,b.lr_total,b.lr_gst,b.lr_grand_total,b.lr_from,b.lr_to,bk.branch_name as bookat,bn.branch_name as from,bn1.branch_name as to, user.user_full_name as consignor,user1.user_full_name as consignee,bb.bank_name as bankn,ss.user_full_name as bill,st.user_full_name as supply,mm.packaging_name as material');
        if($postData['length'] != -1){
            $this->db->limit($postData['length'], $postData['start']);

            $this->db->join('branch bn', 'b.lr_from=bn.branch_id', 'left');
            $this->db->join('branch bn1', 'b.lr_to=bn1.branch_id', 'left');
            $this->db->join('branch bk', 'b.booking_at=bk.branch_id', 'left');
            $this->db->join('ts_users ss', 'b.bill_party=ss.user_id', 'left');
            $this->db->join('ts_users st', 'b.supplay_to_name=st.user_id', 'left');
            $this->db->join('ts_users user', 'b.consignor_name=user.user_id', 'left');
            $this->db->join('ts_users user1', 'b.consignee_name=user1.user_id', 'left');
            $this->db->join('manage_private_packing mm', 'b.pkg_code=mm.packing_id', 'left');
            $this->db->join('ts_bank bb', 'b.bank=bb.bank_id', 'left');



            $this->db->where('b.status','active');
            $this->db->where('b.booking_at', $this->session->userdata('user_branch'));
            $this->db->where('b.bilty_status', 'bilty');
        }

        $query = $this->db->get();
        return $query->result();
    }


    public function countAll(){
        $this->db->from($this->table);
        return $this->db->count_all_results();
    }


    public function countFiltered($postData){
        $this->_get_datatables_query($postData);

        $query = $this->db->get();
        return $query->num_rows();
    }


    private function _get_datatables_query($postData){

        $this->db->from($this->table);

        $i = 0;

        foreach($this->column_search as $item){

            if($postData['search']['value']){

                if($i===0){

                    $this->db->group_start();
                    $this->db->like($item, $postData['search']['value']);

                }else{
                    $this->db->or_like($item, $postData['search']['value']);

                }


                if(count($this->column_search) - 1 == $i){

                    $this->db->group_end();
                }
            }
            $i++;
        }

        if(isset($postData['order'])){
            $this->db->order_by($this->column_order[$postData['order']['0']['column']], $postData['order']['0']['dir']);
        }else if(isset($this->order)){
            $order = $this->order;
            $this->db->order_by(key($order), $order[key($order)]);
        }
    }

错误是

Severity: Notice
Message: Undefined index: search
Filename: bilty/BiltyModel.php
Line Number: 69

我不知道我的代码在哪里哪里错。其他数据表功能正在像下一个上一个或条目数一样工作。但是当我访问seach box时,它给了我上面的错误

0 个答案:

没有答案