Welcome Guest, Not a member yet? Register   Sign In
query with "IN" parameter
#3

(05-23-2019, 06:55 AM)php_rocs Wrote: @utodev,

Any reason why you don't upgrade to CI 3.1.x?
Anyway, my suggestion is to not use the ? but use a variable (of course not forgetting to vet the data prior to putting it in the query).

$x = "'a','b','c'";
$y =3;
$sql =  'SELECT x,y,x from TABLE WHERE x IN ('.$x.') and y=?';
$result = $this->db->query($sql, array($y));

Thank you for your response.

I'm not upgrading cause it is not my server and not my decision to take. Regarding the variable, it isn't an option either. The solution reads this query and several others from an XML which includes also the parameters, it is generated by another application out of my control, and generates a report with the queries results.

Maybe I can use eval to do it with a variable but it would be changing the code too much. The thing is according documentation my second solution should be working, but it doesn't. Maybe that option to include an array as parameter is from CI 3.1 though.

Well, thanks anyway :-)
Reply


Messages In This Thread
query with "IN" parameter - by utodev - 05-23-2019, 03:16 AM
RE: query with "IN" parameter - by php_rocs - 05-23-2019, 06:55 AM
RE: query with "IN" parameter - by utodev - 05-25-2019, 06:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB