Skip to content

Commit 53551d1

Browse files
author
Hadis-Fard
committed
editted subscripts number orders
1 parent 91f2d74 commit 53551d1

1 file changed

Lines changed: 90 additions & 88 deletions

File tree

docs/connect/php/default-php-data-types.md

Lines changed: 90 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -21,92 +21,94 @@ manager: "jhubbard"
2121
# Default PHP Data Types
2222
[!INCLUDE[Driver_PHP_Download](../../includes/driver_php_download.md)]
2323

24-
When retrieving data from the server, the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] converts data to a default PHP data type if no PHP data type has been specified by the user.
25-
26-
When data is returned using the PDO_SQLSRV driver, the data type will either be int or string.
27-
28-
The remainder of this topic discusses default data types using the SQLSRV driver.
29-
30-
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](../../connect/php/how-to-specify-php-data-types.md).
31-
32-
|SQL Server Type|Default PHP Type|Default Encoding|
33-
|-------------------|--------------------|--------------------|
34-
|bigint|String|8-bit character<sup>1</sup>|
35-
|binary|Stream<sup>2</sup>|Binary<sup>3</sup>|
36-
|bit|Integer|8-bit character<sup>1</sup>|
37-
|char|String|8-bit character<sup>1</sup>|
38-
|date<sup>8</sup>|Datetime|Not applicable|
39-
|datetime<sup>8</sup>|Datetime|Not applicable|
40-
|datetime2<sup>8</sup>|Datetime|Not applicable|
41-
|datetimeoffset<sup>8</sup>|Datetime|Not applicable|
42-
|decimal|String|8-bit character<sup>1</sup>|
43-
|float|Float|8-bit character<sup>1</sup>|
44-
|geography|STREAM|Binary<sup>3</sup>|
45-
|geometry|STREAM|Binary<sup>3</sup>|
46-
|image<sup>4</sup>|Stream<sup>2</sup>|Binary<sup>3</sup>|
47-
|int|Integer|8-bit character<sup>1</sup>|
48-
|money|String|8-bit character<sup>1</sup>|
49-
|nchar|String|8-bit character<sup>1</sup>|
50-
|numeric|String|8-bit character<sup>1</sup>|
51-
|nvarchar|String|8-bit character<sup>1</sup>|
52-
|nvarchar(MAX)|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
53-
|ntext<sup>5</sup>|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
54-
|real|Float|8-bit character<sup>1</sup>|
55-
|smalldatetime|Datetime|8-bit character<sup>1</sup>|
56-
|smallint|Integer|8-bit character<sup>1</sup>|
57-
|smallmoney|String|8-bit character<sup>1</sup>|
58-
|sql_variant<sup>9</sup>|String|8-bit character<sup>1</sup>|
59-
|text<sup>6</sup>|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
60-
|time<sup>8</sup>|Datetime|Not applicable|
61-
|timestamp|String|8-bit character<sup>1</sup>|
62-
|tinyint|Integer|8-bit character<sup>1</sup>|
63-
|UDT|Stream<sup>2</sup>|Binary<sup>3</sup>|
64-
|uniqueidentifier|String<sup>7</sup>|8-bit character<sup>1</sup>|
65-
|varbinary|Stream<sup>2</sup>|Binary<sup>3</sup>|
66-
|varbinary(MAX)|Stream<sup>2</sup>|Binary<sup>3</sup>|
67-
|varchar|String|8-bit character<sup>1</sup>|
68-
|varchar(MAX)|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
69-
|xml|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
70-
71-
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.
72-
73-
2. If [sqlsrv_fetch_array](../../connect/php/sqlsrv-fetch-array.md) or [sqlsrv_fetch_object](../../connect/php/sqlsrv-fetch-object.md) 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.
74-
75-
3. Data is returned as a raw byte stream from the server without performing encoding or translation.
76-
77-
4. This is a legacy type that maps to the varbinary(max) type.
78-
79-
5. This is a legacy type that maps to the nvarchar(max) type.
80-
81-
6. This is a legacy type that maps to the varchar(max) type.
82-
83-
7. UNIQUEIDENTIFIERs are GUIDs represented by the following regular expression:
84-
85-
[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}
86-
87-
8. 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](../../connect/php/how-to-retrieve-date-and-time-type-as-strings-using-the-sqlsrv-driver.md).
24+
When retrieving data from the server, the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] converts data to a default PHP data type if no PHP data type has been specified by the user.
25+
26+
When data is returned using the PDO_SQLSRV driver, the data type will either be int or string.
27+
28+
The remainder of this topic discusses default data types using the SQLSRV driver.
29+
30+
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](../../connect/php/how-to-specify-php-data-types.md).
31+
32+
|SQL Server Type|Default PHP Type|Default Encoding|
33+
|-------------------|--------------------|--------------------|
34+
|bigint|String|8-bit character<sup>1</sup>|
35+
|binary|Stream<sup>2</sup>|Binary<sup>3</sup>|
36+
|bit|Integer|8-bit character<sup>1</sup>|
37+
|char|String|8-bit character<sup>1</sup>|
38+
|date<sup>4</sup>|Datetime|Not applicable|
39+
|datetime<sup>4</sup>|Datetime|Not applicable|
40+
|datetime2<sup>4</sup>|Datetime|Not applicable|
41+
|datetimeoffset<sup>4</sup>|Datetime|Not applicable|
42+
|decimal|String|8-bit character<sup>1</sup>|
43+
|float|Float|8-bit character<sup>1</sup>|
44+
|geography|STREAM|Binary<sup>3</sup>|
45+
|geometry|STREAM|Binary<sup>3</sup>|
46+
|image<sup>5</sup>|Stream<sup>2</sup>|Binary<sup>3</sup>|
47+
|int|Integer|8-bit character<sup>1</sup>|
48+
|money|String|8-bit character<sup>1</sup>|
49+
|nchar|String|8-bit character<sup>1</sup>|
50+
|numeric|String|8-bit character<sup>1</sup>|
51+
|nvarchar|String|8-bit character<sup>1</sup>|
52+
|nvarchar(MAX)|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
53+
|ntext<sup>6</sup>|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
54+
|real|Float|8-bit character<sup>1</sup>|
55+
|smalldatetime|Datetime|8-bit character<sup>1</sup>|
56+
|smallint|Integer|8-bit character<sup>1</sup>|
57+
|smallmoney|String|8-bit character<sup>1</sup>|
58+
|sql_variant<sup>7</sup>|String|8-bit character<sup>1</sup>|
59+
|text<sup>8</sup>|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
60+
|time<sup>4</sup>|Datetime|Not applicable|
61+
|timestamp|String|8-bit character<sup>1</sup>|
62+
|tinyint|Integer|8-bit character<sup>1</sup>|
63+
|UDT|Stream<sup>2</sup>|Binary<sup>3</sup>|
64+
|uniqueidentifier|String<sup>9</sup>|8-bit character<sup>1</sup>|
65+
|varbinary|Stream<sup>2</sup>|Binary<sup>3</sup>|
66+
|varbinary(MAX)|Stream<sup>2</sup>|Binary<sup>3</sup>|
67+
|varchar|String|8-bit character<sup>1</sup>|
68+
|varchar(MAX)|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
69+
|xml|Stream<sup>2</sup>|8-bit character<sup>1</sup>|
70+
8871

89-
9. sql_variant is not supported in bidirectional or output parameters.
90-
91-
## Other New SQL Server 2008 Data Types and Features
92-
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 [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)]. The table below summarizes the PHP support for new SQL Server 2008 features.
93-
94-
|Feature|PHP Support|
95-
|-----------|---------------|
96-
|Table-valued parameter|No|
97-
|Sparse columns|Partial|
98-
|Null-bit compression|Yes|
99-
|Large CLR user-defined types (UDTs)|Yes|
100-
|Service principal name|No|
101-
|MERGE|Yes|
102-
|FILESTREAM|Partial|
103-
104-
Partial type support means that you cannot programmatically query for the type of the column.
105-
106-
## See Also
107-
[Constants &#40;Microsoft Drivers for PHP for SQL Server&#41;](../../connect/php/constants-microsoft-drivers-for-php-for-sql-server.md)
108-
[Converting Data Types](../../connect/php/converting-data-types.md)
109-
[PHP Types](http://go.microsoft.com/fwlink/?LinkId=109071)
110-
[Data Types (Transact-SQL)](http://go.microsoft.com/fwlink/?LinkId=109068)
111-
[sqlsrv_field_metadata](../../connect/php/sqlsrv-field-metadata.md)
112-
72+
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.
73+
74+
2. If [sqlsrv_fetch_array](../../connect/php/sqlsrv-fetch-array.md) or [sqlsrv_fetch_object](../../connect/php/sqlsrv-fetch-object.md) 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.
75+
76+
3. Data is returned as a raw byte stream from the server without performing encoding or translation.
77+
78+
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](../../connect/php/how-to-retrieve-date-and-time-type-as-strings-using-the-sqlsrv-driver.md).
79+
80+
5. This is a legacy type that maps to the varbinary(max) type.
81+
82+
6. This is a legacy type that maps to the nvarchar(max) type.
83+
84+
7. sql_variant is not supported in bidirectional or output parameters.
85+
86+
8. This is a legacy type that maps to the varchar(max) type.
87+
88+
9. UNIQUEIDENTIFIERs are GUIDs represented by the following regular expression:
89+
90+
[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}
91+
92+
93+
## Other New SQL Server 2008 Data Types and Features
94+
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 [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)]. The table below summarizes the PHP support for new SQL Server 2008 features.
95+
96+
|Feature|PHP Support|
97+
|-----------|---------------|
98+
|Table-valued parameter|No|
99+
|Sparse columns|Partial|
100+
|Null-bit compression|Yes|
101+
|Large CLR user-defined types (UDTs)|Yes|
102+
|Service principal name|No|
103+
|MERGE|Yes|
104+
|FILESTREAM|Partial|
105+
106+
Partial type support means that you cannot programmatically query for the type of the column.
107+
108+
## See Also
109+
[Constants &#40;Microsoft Drivers for PHP for SQL Server&#41;](../../connect/php/constants-microsoft-drivers-for-php-for-sql-server.md)
110+
[Converting Data Types](../../connect/php/converting-data-types.md)
111+
[PHP Types](http://go.microsoft.com/fwlink/?LinkId=109071)
112+
[Data Types (Transact-SQL)](http://go.microsoft.com/fwlink/?LinkId=109068)
113+
[sqlsrv_field_metadata](../../connect/php/sqlsrv-field-metadata.md)
114+

0 commit comments

Comments
 (0)