Quantcast
Channel: Microsoft Drivers for PHP for SQL Server forum
Viewing all articles
Browse latest Browse all 163

Search paramaters SQLSRV_QUERY for WHERE IN syntax

$
0
0

I wonder if there is a way to pass some values into the parameters option on the sqlsrv_queryfunction. I tried a few things but could not get it to work.

This query is what I want to be executed:

SELECT id, name, etc
FROM sqlTable
WHERE id IN ('1','2','100','314')

I want to pass the WHERE IN values using the params option, like this:

$q ="SELECT id FROM sqlTable WHERE id IN ?";
$p = array(array('1','2','100','314'));
sqlsrv_query($connection, $q, $p);

Right now I'm passing the values directly into the query string, but for obvious security reasons I want to pass them as parameters into the function. Anyone any idea on how to achieve this?


Viewing all articles
Browse latest Browse all 163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>