SELECT WHERE a group of OR IN () conditions AND a group of OR LIKE conditions using CodeIgniter's query builder
19:01 08 Sep 2016

Let's say I have a model method in CodeIgniter returning what user(s) are searching for.

$find = 'something';
$id_user = [1, 5, 20, 21];

So, I have to put that in here but something goes wrong ..

public function find_pr_by_user ($find,$id_users)
{
    $this->db->where_in('req_by_id' . $id_users || 'check_by_id', $id_users || 'approve_by_id', $id_users);
    $this->db->where("(ref_no LIKE '%$find%' || pr_title LIKE '%$find%' || req_date LIKE '%$find%')");
    $query = $this->db->get('pr_data');
    return $query->result();
}

I get error Array to string conversion; input I have is from $find and $id_users that can be anything. I expected this logic, give me all array from table PR_DATA which is have %$find% on column ref_no or pr_title or req_date but only have $id_users *(1 or 5 or 20 or 21) in column req_by_id or check_by_id or approve_by_id.

How do I properly use query builder methods to achieve these sets of conditions?

php codeigniter where-clause sql-like where-in