This topic and the topics in this section discuss how to retrieve data.
SQLSRV Driver
The SQLSRV driver of the Microsoft Drivers for PHP for SQL Server provides the following options for retrieving data from a result set:
Note |
---|
When you use any of the functions mentioned above, avoid null comparisons as the criterion for exiting loops. Because sqlsrv functions return false when an error occurs, the following code could result in an infinite loop upon an error in sqlsrv_fetch_array: /* This code could result in an infinite loop. It is recommended that you do NOT use null comparisons as the criterion for exiting loops, as is done here. */ do{ $result = sqlsrv_fetch_array($stmt); } while( !is_null($result)); |
If your query retrieves more than one result set, you can move to the next result set with sqlsrv_next_result.
Beginning in version 1.1 of the Microsoft Drivers for PHP for SQL Server, you can use sqlsrv_has_rows to see if a result set has rows.
PDO_SQLSRV Driver
The PDO_SQLSRV driver of the Microsoft Drivers for PHP for SQL Server provides the following options for retrieving data from a result set:
If your query retrieves more than one result set, you can move to the next result set with PDOStatement::nextRowset.
You can see how many rows are in a result set if you specify a scrollable cursor, and then call PDOStatement::rowCount.
PDO::prepare lets you specify a cursor type. Then, with PDOStatement::fetch you can select a row. See PDO::prepare for a sample and more information.
In This Section
Topic |
Description |
---|---|
Provides an overview of how to stream data from the server, and provides links to specific use cases. |
|
Describes how to use directional parameters when calling a stored procedure. |
|
Demonstrates how to create a result set with rows that you can access in any order when using the SQLSRV driver. |
|
How to: Retrieve Date and Time Type as Strings Using the SQLSRV Driver |
Describes how to retrieve date and time types as strings. |