SQL Server Datatype to PHP Datatype

SQL Server Type Default PHP Type Default Encoding
bigint String 8-bit character1
binary Stream2 Binary3
bit Integer 8-bit character1
char String 8-bit character1
date4 Datetime Not applicable
datetime4 Datetime Not applicable
datetime24 Datetime Not applicable
datetimeoffset4 Datetime Not applicable
decimal String 8-bit character1
float Float 8-bit character1
geography STREAM Binary3
geometry STREAM Binary3
image5 Stream2 Binary3
int Integer 8-bit character1
money String 8-bit character1
nchar String 8-bit character1
numeric String 8-bit character1
nvarchar String 8-bit character1
nvarchar(MAX) Stream2 8-bit character1
ntext6 Stream2 8-bit character1
real Float 8-bit character1
smalldatetime Datetime 8-bit character1
smallint Integer 8-bit character1
smallmoney String 8-bit character1
sql_variant7 String 8-bit character1
text8 Stream2 8-bit character1
time4 Datetime Not applicable
timestamp String 8-bit character1
tinyint Integer 8-bit character1
UDT Stream2 Binary3
uniqueidentifier String9 8-bit character1
varbinary Stream2 Binary3
varbinary(MAX) Stream2 Binary3
varchar String 8-bit character1
varchar(MAX) Stream2 8-bit character1
xml Stream2 8-bit character1
  1. 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.
  2. 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.
  3. Data is returned as a raw byte stream from the server without performing encoding or translation.
  4. 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.
  5. This is a legacy type that maps to the varbinary(max) type.
  6. This is a legacy type that maps to the nvarchar(max) type.
  7. sql_variant is not supported in bidirectional or output parameters.
  8. This is a legacy type that maps to the varchar(max) type.
  9. UNIQUEIDENTIFIERs are GUIDs represented by the following regular expression: [0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-f]{4}-[0-9a-fA-f]{4}-[0-9a-fA-F]{12}

 

SOURCE: https://docs.microsoft.com/en-us/sql/connect/php/default-php-data-types

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.