[eluser]Dandy_andy[/eluser]
I'm using the active record class to return results for a database query. I want to exclude some results from the query using $this->db->where_not_in(); but something strange is happening that I can't explain. I have a statement in my database query which reads:-
Code:
$this->db->where_not_in('members.mem_id', $excluded_members);
Now if I manually generate an array to pass through this statement like the one below, the query works fine.
Code:
$excluded_members = array(9012, 9021, 9031);
However, I want to dynamically create the array and I'm using the following function to do so:-
Code:
public function excluded_members($mem_id) {
$limit_array = 100; //limit array to 100 results. Only the most recent 100 results will be returned as exclusions
$data = array();
$this->db->select('matched_mem_id');
$this->db->where('mem_id', $mem_id);
$this->db->order_by('datetime', 'DESC');
$this->db->limit($limit_array);
$query = $this->db->get('search_exclusions');
$row = $query->result_array();
foreach($row as $value)
{
array_push($data, (int)$value['matched_mem_id']); //(int) to convert values to integer
}
return $data;
}//excluded_members
The value returned and outputted using var_dump or var_export is identical to my original hand written array yet the dynamically created array $excluded_members is causing my database query to crash. Does anyone know why? What am I missing here?