I am using the sqlsrv ms drivers for php, which work fine (tested with normal queries), I have also tested it with running a stored procedure to update table data which also wor
Supposing that the stored procedure is returning the contents of one table with a single SELECT statement, using its output should be as simple as using the result of sqlsrv_query as you would any other selection query result (i.e. using sqlsrv_fetch_object/array on the result)! So the stored proc could look something like this:
CREATE STORED PROCEDURE test
AS
-- do some other stuff here
-- ...
SELECT * FROM test
GO
And in your php:
// establish db connection, initialize
// ...
$sql = "{call test}"
$result = sqlsrv_query($conn, $sql);
while (sqlsrv_fetch_object($result))
{
// do something with the data
// ...
}
You need to call sqlsrv_fetch()
and sqlsrv_get_field()
to get data from the returned statement.
From the example code in the manual for sqlsrv_get_field:
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false )
{
echo "Error in statement preparation/execution.\n";
die( print_r( sqlsrv_errors(), true));
}
/* Make the first row of the result set available for reading. */
if( sqlsrv_fetch( $stmt ) === false )
{
echo "Error in retrieving row.\n";
die( print_r( sqlsrv_errors(), true));
}
/* Note: Fields must be accessed in order.
Get the first field of the row. Note that no return type is
specified. Data will be returned as a string, the default for
a field of type nvarchar.*/
$name = sqlsrv_get_field( $stmt, 0);
echo "$name: ";
Beyond that, I am not sure when you say you will receive multiple values whether you mean there will be multiple fields in one row (in which case you will want to make more calls to sqlsrv_get_field()
), more than one row (in which case you will have to use a while loop with the call to sqlsrv_fetch() in the loop), or more than one result set (in which case you'll want a while loop using sqlsrv_next_result()).