我有这个功能我想在条件del_status = 0中选择数据 我准备好检索数据,但这种情况没有完成 这个陈述中的错误是什么
public function SearchData($tablename,$data)
{
$this->db->select("*");
$this->db->from($tablename);
$this->db->like('username', $data);
$this->db->or_like('fullname', $data);
$this->db->or_like('email', $data);
$this->db->where('del_status','1');
//$this->db->where('del_status'== '1');
$sql = $this->db->get();
return $sql->result();
}
如果我写这个声明它可以正常工作
$select_query = "select * from $tablename where username like'%$data%' AND del_status ='1' ";
$query = $this->db->query($select_query);
return $query->result();
答案 0 :(得分:0)
试试这个:
public function search($data){
$query = $this->db->where('del_status', 0)
->group_start()
->like('table_column', $data)
->or_like('table_column', $data)
->group_end()
->get('tablename');
return $query->result_array();
}