i have this array of objects as a result of the following code:
$varIds = $this->user_model->get_var_id(...);
it produces something like this :
[ {var_id: "141"} {var_id: "143"} {var_id: "146"} {var_id: "149"} ]
next step, sending this array to model like this:
$this->user_model->get_item_options_values_filter(...,$varIds);
next, filtering like this:
$this->db->where_in('items_options_value.var_id',$varIds);
i want to filter the rows based on the values in the $varIds array of objects, but this does not work as the where_in clause gives error array to string conversion, so how to compare the value of the var_id column with the values in $varIds?
Advertisement
Answer
i had to first convert array of objects into array of values like this :
$names = array(); foreach($varIds as $v){ array_push($names,$v['var_id']); }
then :
$this->db->where_in('items_options_value.var_id',$names);