phpcodeigniterselectquery-builderwhere-in

CodeIgniter's where_in() method finds no matches using a comma-separated string of values


I have the following query.

SELECT id FROM content WHERE id IN ('40,41,45')

Query above returns the content of id 40, 41, 45.
Thus, the result is 3 rows will be returned.

In my case, the previous query returns one row only, the content that has id 40.

Why does not return the rows that have these ids?


Edit:
I'm using codeigniter query.

$this->db->select('*')->where_in('id', $content)->get('content');

Thus, the query will be like this

SELECT * FROM (`content`) WHERE `id` IN ('40,41,45') 

How can I remove the single quotes from the query ?


Solution

  • With codeigniter your variable $content must be a PHP array.