我使用datatable从mysql获取数据。数据表显示数据,但是当我从搜索框中搜索任何数据时。它会显示一条警告信息。
这是我的型号代码。
$this->db->from($this->table);
$i=0;//for search box.
foreach ($this->column_search as $item)//take column_search item in the loop check request and provide result.
{
if($_POST['search']['value'])//search box take request value if it's POST request
{
if($i===0) // first loop. if when i is equal and identical
{
$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($this->column_search) - 1 == $i) //last loop
$this->db->group_end(); //close bracket
}
$i++;
}
if(isset($_POST['order'])) // here order processing
{
$this->db->order_by($this->column_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)]);
}
答案 0 :(得分:0)
它可能缺少列,检查结果数据