我有数据表,其中的搜索框不起作用

时间:2019-07-09 11:00:24

标签: php jquery mysql sql codeigniter

我的搜索框在数据表中不起作用。...显示错误提示

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)]);
        }
    }

它还在控制台中显示错误,也正在显示数据库错误。

  

错误号:1064   您的SQL语法有误;请查看与您的MariaDB服务器版本相对应的手册,以获取正确的语法,以在'as mcatname之类的'%s%'ESCAPE'!'附近使用。或sssub_category1_namesname LIK',位于第12行

SELECT * FROM `products` `p` 
    LEFT JOIN `main_category` `mm` ON `p`.`main_category_id` = `mm`.`main_category_id` 
    LEFT JOIN `sub_category` `ss` ON `p`.`sub_category_id` = `ss`.`sub_category_id` 
WHERE (    `p`.`product_id` LIKE '%s%' ESCAPE '!' 
        OR `p`.`images` LIKE '%s%' ESCAPE '!' 
        OR `p`.`title` LIKE '%s%' ESCAPE '!' 
        OR `p`.`price` LIKE '%s%' ESCAPE '!' 
        OR `p`.`discount` LIKE '%s%' ESCAPE '!' 
        OR `p`.`discount_price` LIKE '%s%' ESCAPE '!' 
        OR `mm`.`main_category_name` as `mcatname` LIKE '%s%' ESCAPE '!' 
        OR `ss`.`sub_category1_name` as `sname` LIKE '%s%' ESCAPE '!' ) 
ORDER BY `p`.`product_id` ASC LIMIT 10
  

文件名:models / admin / Product_model.php   行号:31

0 个答案:

没有答案