php - datatables serverside join in codeigniter -
i tried combine data using datatable serverside in codeigniter via ajax, error result, this
message: call member function result() on boolean
filename: models/model_masterdata_menu.php
line number: 66
private function _get_datatables_query() { //term value of $_request['search']['value'] $column_search = array('m.menu_id, m.menu_nama, m.menu_url, sm.statusmenu_nama'); $column_order = array('m.menu_id, m.menu_nama, m.menu_url, sm.statusmenu_nama',null); $order = array('m.menu_id' => 'desc'); $this->db->select('m.menu_id, m.menu_nama, m.mmenu_url, sm.statusmenu_nama'); $this->db->from('menu m'); $this->db->join('status_menu sm', 'sm.statusmenu_id = m.statusmenu_id','left'); $i = 0; foreach ($column_search $item) // loop column { if($_post['search']['value']) // if datatable send post search { if($i===0) // first loop { $this->db->group_start(); // open bracket. query or clause better bracket. because maybe can combine other and. $this->db->like($item, $_post['search']['value']); } else { $this->db->or_like($item, $_post['search']['value']); } if(count($column_search) - 1 == $i) //last loop $this->db->group_end(); //close bracke } $i++; } if(isset($_post['order'])) // here order processing { $this->db->order_by($order[$_post['order']['0']['column']], $_post['order']['0']['dir']); } else if(isset($this->order)) { /*$order = $this->order;*/ $this->db->order_by(key($order), $order[key($order)]); } } function get_datatables() { $this->_get_datatables_query(); /*$this->_get_datatables_query();*/ if($_post['length'] != -1) $this->db->limit($_post['length'], $_post['start']); $result = $query->result(); # added }
what's wrong? can me?
i don't know why tells call member function result() on boolean
because based on code didnt't declare $query
properly.
anyway did try ?
function get_datatables() { $this->_get_datatables_query(); if($_post['length'] != -1) $this->db->limit($_post['length'], $_post['start']); $query = $this->db->get(); return ($query->num_rows() > 0) ? $query->result() : false; }
Comments
Post a Comment