I tried to combine the data using datatable serverside in codeigniter via ajax, But i get the error result, like this
Message: Call to a member function result() on boolean
Filename: models/model_masterdata_menu.php
Line Number: 66
private function _get_datatables_query()
{ //term is 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 as m');
$this->db->join('status_menu sm', 'sm.statusmenu_id = m.statusmenu_id','left');
$i = 0;
foreach ($column_search as $item) // loop column
{
if($_POST['search']['value']) // if datatable send POST for search
{
if($i===0) // first loop
{
$this->db->group_start(); // open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with 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 anyone help me?
i don't know why it tells you Call to a member function result() on boolean
because based on your code you didnt't even declare $query
properly.
Anyway did you try something like that ?
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.