Voting

: min(one, eight)?
(Example: nine)

The Note You're Voting On

anon at example dot com
6 years ago
Note that you can get multiple results when executing a single query, for example:

<?php
$stmt
= sqlsrv_query($conn, "use dbname; select 1");
?>

Running the same query in tsql or management studio works as expected. However, with sqlsrv_* functions, this gives you two result sets -- one for the "use" and one for the "select".

<?php
// Advance the result pointer from "use" to "select"
sqlsrv_next_result($stmt);

// Now you can read the "1"
print_r(sqlsrv_fetch_array($stmt));
?>

For a complex query that begins by creating/populating temporary tables, you will need to advance the result pointer past such statements to get data from the final select statement. In older PHP versions (using FreeTDS-based mssql connectivity at least), you'd get only the last result so didn't need to take this into account.

<< Back to user notes page

To Top