Ghanshyam Nakiya
Ghanshyam Nakiya

Reputation: 1712

Codeigniter How to in Array use where OR, AND clause

I am looking for query in Codeigniter works like where OR, AND both works.

This is working Perfect!

$srcArr2['emp_id']=8;
$srcArr2['status']='2';
$this->db->where($srcArr2);
$query = $this->db->get('tickets');
$res = $query->result_array(); // as array
print_r ($res);

query is:

Need to add OR in where with $srcArr1['ass_id']=12; I try but not working.

$srcArr1['ass_id']=12;
$srcArr2['emp_id']=8;
$srcArr2['status']='2';
$this->db->where($srcArr2);
$this->db->where_in($srcArr1);
$query = $this->db->get('tickets');
$res = $query->result_array(); // as array
print_r ($res);

Thank You, in Advance for help

Upvotes: 0

Views: 52

Answers (2)

Rahul
Rahul

Reputation: 18557

You can use or_where_in to achieve the same,

$this->db->or_where_in($srcArr1);

Official doc.

Upvotes: 1

Related Questions