This topic lists the constants that are defined by the SQL Server Driver for PHP.
The following table lists the constants that are used to specify if sqlsrv_errors returns errors, warnings, or both.
|
Value
|
Description
|
|---|
|
SQLSRV_ERR_ALL
|
Errors and warnings generated on the last sqlsrv function call are returned. This is the default value.
|
|
SQLSRV_ERR_ERRORS
|
Errors generated on the last sqlsrv function call are returned.
|
|
SQLSRV_ERR_WARNINGS
|
Warnings generated on the last sqlsrv function call are returned.
|
The following table lists the constants that are used to specify the type of array returned by sqlsrv_fetch_array.
|
SQLSRV constant
|
Description
|
|---|
|
SQLSRV_FETCH_ASSOC
|
sqlsrv_fetch_array returns the next row of data as an associative array.
|
|
SQLSRV_FETCH_BOTH
|
sqlsrv_fetch_array returns the next row of data as an array with both numeric and associative keys. This is the default value.
|
|
SQLSRV_FETCH_NUMERIC
|
sqlsrv_fetch_array returns the next row of data as a numerically indexed array.
|
For more information about how to use these constants, see How to: Retrieve Data as an Array.
This section lists the constants that are used to change the logging settings with sqlsrv_configure. For more information about logging activity, see Logging Activity.
The following table lists the constants that can be used as the value for the LogSubsystems setting:
|
SQLSRV constant (integer equivalent in paraentheses)
|
Description
|
|---|
|
SQLSRV_LOG_SYSTEM_ALL (-1)
|
Turns on logging of all subsystems.
|
|
SQLSRV_LOG_SYSTEM_CONN (2)
|
Turns on logging of connection activity.
|
|
SQLSRV_LOG_SYSTEM_INIT (1)
|
Turns on logging of initialization activity.
|
|
SQLSRV_LOG_SYSTEM_OFF (0)
|
Turns logging off.
|
|
SQLSRV_LOG_SYSTEM_STMT (4)
|
Turns on logging of statement activity.
|
|
SQLSRV_LOG_SYSTEM_UTIL (8)
|
Turns on logging of error functions activity (such as handle_error and handle_warning).
|
The following table lists the constants that can be used as the value for the LogSeverity setting:
|
SQLSRV constant (integer equivalent in paraentheses)
|
Description
|
|---|
|
SQLSRV_LOG_SEVERITY_ALL (-1)
|
Specifies that errors, warnings, and notices will be logged.
|
|
SQLSRV_LOG_SEVERITY_ERROR (1)
|
Specifies that errors will be logged.
|
|
SQLSRV_LOG_SEVERITY_NOTICE (4)
|
Specifies that notices will be logged.
|
|
SQLSRV_LOG_SEVERITY_WARNING (2)
|
Specifies that warnings will be logged.
|
The following table lists the constants that you can use to determine whether or not a column is nullable or if this information is not available. You can compare the value of the Nullable key that is returned by sqlsrv_field_metadata to determine the column's nullable status.
|
SQLSRV constant (integer equivalent in paraentheses)
|
Description
|
|---|
|
SQLSRV_NULLABLE_YES (0)
|
The column is nullable.
|
|
SQLSRV_NULLABLE_NO (1)
|
The column is not nullable.
|
|
SQLSRV_NULLABLE_UNKNOWN (2)
|
It is not known if the column is nullable.
|
The following list contains the constants for specifying parameter direction when you call sqlsrv_query or sqlsrv_prepare.
|
SQLSRV constant
|
Description
|
|---|
|
SQLSRV_PARAM_IN
|
Indicates an input parameter.
|
|
SQLSRV_PARAM_INOUT
|
Indicates a bidirectional parameter.
|
|
SQLSRV_PARAM_OUT
|
Indicates an output parameter.
|
The following table lists the constants that are used to describe PHP data types. For information about PHP data types, see PHP Types.
|
SQLSRV constant
|
PHP data type
|
|---|
|
SQLSRV_PHPTYPE_INT
|
Integer
|
|
SQLSRV_PHPTYPE_DATETIME
|
Datetime
|
|
SQLSRV_PHPTYPE_FLOAT
|
Float
|
|
SQLSRV_PHPTYPE_STREAM(<encoding>1)
|
Stream
|
|
SQLSRV_PHPTYPE_STRING(<encoding>1)
|
String
|
1. SQLSRV_PHPTYPE_STREAM and SQLSRV_PHPTYPE_STRING accept a parameter that specifies the stream encoding. The following table contains the SQLSRV constants that are acceptable parameters, and a description of the corresponding encoding.
|
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 that is 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.
|
|
"UTF-8"
|
Data is returned in the UTF-8 encoding. This constant was added in version 1.1 of the SQL Server Driver for PHP. For more information about UTF-8 support, see How to: Send and Retrieve UTF-8 Data Using Built-In UTF-8 Support.
|
Note: |
|---|
|
When you use SQLSRV_PHPTYPE_STREAM or SQLSRV_PHPTYPE_STRING, the encoding must be specified. If no parameter is supplied, an error will be returned.
|
For more information about these constants, see How to: Specify PHP Data Types, How to: Retrieve Character Data as a Stream.
The following table lists the constants that are used to describe SQL Server data types. Some constants require parameters that correspond to precision, scale, and/or length. For information about SQL Server data types, see Data Types (Transact-SQL). For information about precision, scale, and length, see Precision, Scale, and Length (Transact-SQL).
|
SQLSRV constant
|
SQL Server data type
|
|---|
|
SQLSRV_SQLTYPE_BIGINT
|
bigint
|
|
SQLSRV_SQLTYPE_BINARY
|
binary
|
|
SQLSRV_SQLTYPE_BIT
|
bit
|
|
SQLSRV_SQLTYPE_CHAR($charCount)
|
char
|
|
SQLSRV_SQLTYPE_DATE
|
date4
|
|
SQLSRV_SQLTYPE_DATETIME
|
datetime
|
|
SQLSRV_SQLTYPE_DATETIME2
|
datetime24
|
|
SQLSRV_SQLTYPE_DATETIMEOFFSET
|
datetimeoffset4
|
|
SQLSRV_SQLTYPE_DECIMAL($precision, $scale)
|
decimal
|
|
SQLSRV_SQLTYPE_FLOAT
|
float
|
|
SQLSRV_SQLTYPE_IMAGE
|
image1
|
|
SQLSRV_SQLTYPE_INT
|
int
|
|
SQLSRV_SQLTYPE_MONEY
|
money
|
|
SQLSRV_SQLTYPE_NCHAR($charCount)
|
nchar
|
|
SQLSRV_SQLTYPE_NUMERIC($precision, $scale)
|
numeric
|
|
SQLSRV_SQLTYPE_NVARCHAR($charCount)
|
nvarchar
|
|
SQLSRV_SQLTYPE_NVARCHAR('max')
|
nvarchar(MAX)
|
|
SQLSRV_SQLTYPE_NTEXT
|
ntext2
|
|
SQLSRV_SQLTYPE_REAL
|
real
|
|
SQLSRV_SQLTYPE_SMALLDATETIME
|
smalldatetime
|
|
SQLSRV_SQLTYPE_SMALLINT
|
smallint
|
|
SQLSRV_SQLTYPE_SMALLMONEY
|
smallmoney
|
|
SQLSRV_SQLTYPE_TEXT
|
text3
|
|
SQLSRV_SQLTYPE_TIME
|
time4
|
|
SQLSRV_SQLTYPE_TIMESTAMP
|
timestamp
|
|
SQLSRV_SQLTYPE_TINYINT
|
tinyint
|
|
SQLSRV_SQLTYPE_UNIQUEIDENTIFIER
|
uniqueidentifier
|
|
SQLSRV_SQLTYPE_UDT
|
UDT
|
|
SQLSRV_SQLTYPE_VARBINARY($byteCount)
|
varbinary
|
|
SQLSRV_SQLTYPE_VARBINARY('max')
|
varbinary(MAX)
|
|
SQLSRV_SQLTYPE_VARCHAR($charCount)
|
varchar
|
|
SQLSRV_SQLTYPE_VARCHAR('max')
|
varchar(MAX)
|
|
SQLSRV_SQLTYPE_XML
|
xml
|
-
This is a legacy type that maps to the varbinary(max) type.
-
This is a legacy type that maps to the newer nvarchar type.
-
This is a legacy type that maps to the newer varchar type.
-
Support for this type was added in version 1.1 of the SQL Server Driver for PHP.
The following table lists the SQLTYPE constants that accept parameters and the range of values allowed for the parameter.
|
SQLTYPE
|
Parameter
|
Allowable range for parameter
|
|---|
|
SQLSRV_SQLTYPE_CHAR,
SQLSRV_SQLTYPE_VARCHAR
|
charCount
|
1 - 8000
|
|
SQLSRV_SQLTYPE_NCHAR,
SQLSRV_SQLTYPE_NVARCHAR
|
charCount
|
1 - 4000
|
|
SQLSRV_SQLTYPE_BINARY,
SQLSRV_SQLTYPE_VARBINARY
|
byteCount
|
1 - 8000
|
|
SQLSRV_SQLTYPE_DECIMAL,
SQLSRV_SQLTYPE_NUMERIC
|
precision
|
1 - 38
|
|
SQLSRV_SQLTYPE_DECIMAL,
SQLSRV_SQLTYPE_NUMERIC
|
scale
|
1 - precision
|
Transaction Isolation Level Constants
The TransactionIsolation key, which is used with sqlsrv_connect, accepts one of the following constants:
-
SQLSRV_TXN_READ_UNCOMMITTED
-
SQLSRV_TXN_READ_COMMITTED
-
SQLSRV_TXN_REPEATABLE_READ
-
SQLSRV_TXN_SNAPSHOT
-
SQLSRV_TXN_SERIALIZABLE
Cursor and Scrolling Constants
The following constants specify the kind of cursor that you can use in a result set:
-
SQLSRV_CURSOR_FORWARD
-
SQLSRV_CURSOR_STATIC
-
SQLSRV_CURSOR_DYNAMIC
-
SQLSRV_CURSOR_KEYSET
The following constants specify which row to select in the result set:
-
SQLSRV_SCROLL_NEXT
-
SQLSRV_SCROLL_PRIOR
-
SQLSRV_SCROLL_FIRST
-
SQLSRV_SCROLL_LAST
-
SQLSRV_SCROLL_ABSOLUTE
-
SQLSRV_SCROLL_RELATIVE
For information on using these constants, see Specifying a Cursor Type and Selecting Rows.
Other Resources
API Reference (SQL Server Driver for PHP)
>