Hi all,
I have a query like this:
Code:
SELECT x,y,x from TABLE WHERE x IN (?) and y=?
My first approach was just preparing the values of x as a string, considering the values are also strings, so I got something like:
Code:
$x = "'a','b','c'";
$y =3;
$sql = 'SELECT x,y,x from TABLE WHERE x IN (?) and y=?';
$result = $this->db->query($sql, array($x, $y));
That didn't work as codeigniter escapes the in string.
Then I read the manual and found In parameters should be passed as array, ok, new try:
Code:
$x =array('a','b','c');
$y =3;
$sql = 'SELECT x,y,x from TABLE WHERE x IN (?) and y=?';
$result = $this->db->query($sql, array($x, $y));
Then i got a mesage saying this query is invalid:
Code:
SELECT x,y,x from TABLE WHERE x IN (Array) and y=3
I'm user Code igniter 2.
Note: due to some restrictions in what I'm using this for, I cannot use other database features like using db->where_in() or similar, just db->query()
Thanks!
Am I doing anything wrong?