Shambu Shambu - 1 year ago 125
SQL Question

How to use array values in where clause in CodeIgniter

I am trying to check array value in where condition.

My try:

$con=array('ad_no',$ao);
$this->db->where('ad_no',$con);
$query = $this->db->get('duration');
$r = $query->result_array();


But I got the following error:


unknown column 'array' in 'where clause'

Answer Source

Try a loop:

foreach($ad_no as $key=>$id){               
    $this->db->where('ad_no',$id); 
    $query = $this->db->get('duration');
    $r = $query->result_array(); 
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download