Bind with commas
Bind with commas
I have the following code:
$q->where( 'unit', '(:units)', 'IN', false );
$q->bind( ':units', '4210, 4211' );
If I have 4210 it works but the ',' seems to be a problem. I tried using '\,' to escape the ',' but that still doesn't work.
Note: $q->where( 'unit', '(4210, 4211)', 'IN', false ); works.
Any guidance? Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Yes, unfortunately that wouldn't work since it would effectively cope out like:
WHERE unit IN ('4210, 4211')
(note the string quotes).I've just had a look at the PHP documentation and I don't actually see a way of doing what you want with the PDO methods. What you would probably need to do is use
or_where
and loop over your array of values. UsingIN
is probably only useful if you get the results from an innerSELECT
.Allan
That worked. So others see the complete solution, this is how I changed things: