I have tried a few different approaches to this problem with no solutions so far. I am receiving this error message:
Unknown column 'Array' in 'where clause'
SELECT * FROM (Articles
) WHERE id
IN (Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array)
Here is my model code:
function getStarNews($user_id) {
$this->db->select('id');
$this->db->where('user_id', $user_id);
$query = $this->db->get('table1');
foreach ($query->result_array() as $id)
{
//echo $id['id']."<br>"; //displays all of the correct ids I am trying to pass to the where_in()
}
$id = $query->result_array();
$this->db->where_in('id', $id); //pass array of 'id' from above query
$data = $this->db->get('Articles');
return $data->result_array();
}
If I alter the id array to contain only 1 value then the where_in() clause works fine and outputs the row of data matching the single 'id'.
I've looked all over stack and google for help in using where_in() and I think I have everything correct or have tried a few different methods for passing an array correctly.
Thanks for the help.
EDIT: In the end I will be outputting this data with my controller using:
$this->output->set_output(json_encode($data));
For testing purposes I was just skipping the JSON and trying to output the data with PHP from the model directly.