in Codeigniter This is my Controller => wishlist function
$data = array(
'user_id' => $this->_user_id
);
$order_by = "id";
$query = $this->Database_model->get_data('wishlist','*', $data, $order_by);
print_r($query);
RESULT:
Array
(
[0] => stdClass Object
(
[id] => 1
[item_id] => 2
[user_id] => 2
[tarix] => 2018-03-13 00:00:00
)
[1] => stdClass Object
(
[id] => 2
[item_id] => 15
[user_id] => 2
[tarix] => 2018-03-13 00:00:00
)
[2] => stdClass Object
(
[id] => 3
[item_id] => 10
[user_id] => 2
[tarix] => 2018-03-13 00:00:00
)
)
And now I want to get all "items" table datas WHERE id = all these "item_id" inside array.
I tried to create new array and push all item_id inside it, using foreach, but in Codeigniter I can't give it to query.
where instatement? - Kisaragiwhere id in(select id ...)- chris85where inyour query needs to use$this-db->where_in('column', $array);Please edit your question to includeget_data()- KisaragiCodeigniterbut you can use a subquery in mysql easily enough which should give you what you want. Roughlyselect * from items where id in (select item_id from wishlist where ...)- chris85