Retrieving Data as a Stream
SQL Server Driver for PHP Version 1.0 and Version 1.1
Retrieving Data as a Stream

The SQL Server Driver for PHP takes advantage of streams for retrieving large amounts of data. The topics in this section provide details about how to retrieve data as a stream.

The following steps summarize how to retrieve data as a stream:

  1. Prepare and execute a Transact-SQL query with sqlsrv_query or the combination of sqlsrv_prepare/sqlsrv_execute.
  2. Use sqlsrv_fetch to move to the next row in the result set.
  3. Use sqlsrv_get_field to retrieve a field from the row. Specify that the data is to be retrieved as a stream by using SQLSRV_PHPTYPE_STREAM(<encoding>) as the third parameter in the function call. This table lists the constants used to specify encodings and their descriptions:

    SQLSRV Constant Description

    SQLSRV_ENC_BINARY

    Data is returned as a raw byte stream from the server without performing encoding or translation.

    SQLSRV_ENC_CHAR

    Data is returned in 8-bit characters as specified in the code page of the Windows locale set on the system. Any multi-byte characters or characters that do not map into this code page are substituted with a single byte question mark (?) character.

Cc296155.note(en-US,SQL.90).gifNote:
Some data types are returned as streams by default. For more information, see Default PHP Data Types.

In This Section

Topic Description

Data Types with Stream Support

Lists the SQL Server data types that can be retrieved as streams.

How to: Retrieve Character Data as a Stream

Demonstrates how to retrieve character data as a stream.

How to: Retrieve Binary Data as a Stream

Demonstrates how to retrieve binary data as a stream.

See Also

Concepts

Comparing Data Retrieval Functions
SQLSRV Constants

Other Resources

Retrieving Data

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View