Default PHP Data Types
When retrieving data from the server, the Microsoft Drivers for PHP for SQL Server converts data to a default PHP data type if no PHP data type has been specified by the user.
When data is returned using the PDO_SQLSRV driver, the data type will either be int or string.
The remainder of this topic discusses default data types using the SQLSRV driver.
The following table lists the SQL Server data type (the data type being retrieved from the server), the default PHP data type (the data type to which data is converted), and the default encoding for streams and strings. For details about how to specify data types when retrieving data from the server, see How to: Specify PHP Data Types.
|SQL Server Type||Default PHP Type||Default Encoding|
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.
If sqlsrv_fetch_array or sqlsrv_fetch_object is used to retrieve data that has a default PHP type of Stream, the data will be returned as a string with the same encoding as the stream. For example, if a SQL Server binary type is retrieved by using sqlsrv_fetch_array, the default return type will be a binary string.
Data is returned as a raw byte stream from the server without performing encoding or translation.
Date and time types can be retrieved as strings. For more information, see How to: Retrieve Date and Time Type as Strings Using the SQLSRV Driver.
This is a legacy type that maps to the varbinary(max) type.
This is a legacy type that maps to the nvarchar(max) type.
sql_variant is not supported in bidirectional or output parameters.
This is a legacy type that maps to the varchar(max) type.
UNIQUEIDENTIFIERs are GUIDs represented by the following regular expression:
Other New SQL Server 2008 Data Types and Features
Data types that are new in SQL Server 2008 and that exist outside of columns (such as table-valued parameters) are not supported in the Microsoft Drivers for PHP for SQL Server. The table below summarizes the PHP support for new SQL Server 2008 features.
|Large CLR user-defined types (UDTs)||Yes|
|Service principal name||No|
Partial type support means that you cannot programmatically query for the type of the column.