---
title: "Connection Options | Microsoft Docs"
ms.custom: ""
ms.date: 12/12/2019
ms.prod: sql
ms.prod_service: connectivity
ms.reviewer: ""
ms.technology: connectivity
ms.topic: conceptual
ms.assetid: 6d1ea295-8e34-438e-8468-4bbc0f76192c
author: David-Engel
ms.author: v-daenge
---
# Connection Options
[!INCLUDE[Driver_PHP_Download](../../includes/driver_php_download.md)]
This topic lists the options that are permitted in the associative array (when using [sqlsrv_connect](../../connect/php/sqlsrv-connect.md) in the SQLSRV driver) or the keywords that are permitted in the data source name (dsn) (when using [PDO::__construct](../../connect/php/pdo-construct.md) in the PDO_SQLSRV driver).
## Table of Connection Options
|Key|Value|Description|Default|
|-------|---------|---------------|-----------|
|AccessToken|String|The byte string of the Azure AD Access Token extracted from an OAuth JSON response.
The connection string must not contain a user ID, password, or the `Authentication` keyword. For more information, refer to [Connect Using Azure Active Directory Authentication](../../connect/php/azure-active-directory.md)|Not set.|
|APP|String|Specifies the application name used in tracing.|Not set.|
|ApplicationIntent|String|Declares the application workload type when connecting to a server. Possible values are **ReadOnly** and **ReadWrite**.
For more information about [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] support for [!INCLUDE[ssHADR](../../includes/sshadr_md.md)], see [Support for High Availability, Disaster Recovery](../../connect/php/php-driver-for-sql-server-support-for-high-availability-disaster-recovery.md).|ReadWrite|
|AttachDBFileName|String|Specifies which database file the server should attach.|Not set.|
|Authentication|One of the following strings:
**SqlPassword**
**ActiveDirectoryPassword**
**ActiveDirectoryMsi**|Specifies the authentication mode.
For more information, refer to [Connect Using Azure Active Directory Authentication](../../connect/php/azure-active-directory.md)|Not set.|
|CharacterSet
(not supported in the PDO_SQLSRV driver)|String|Specifies the character set used to send data to the server.
Possible values are SQLSRV_ENC_CHAR and UTF-8. For more information, see [How to: Send and Retrieve UTF-8 Data Using Built-In UTF-8 Support](../../connect/php/how-to-send-and-retrieve-utf-8-data-using-built-in-utf-8-support.md).|SQLSRV_ENC_CHAR|
|ColumnEncryption|One of the following strings:
**Enabled**
**Disabled**
A string identifying the attestation protocol and URL for attesting the enclave|Specifies whether the Always Encrypted feature is enabled or not. If an attestation protocol and URL are specified, Always Encrypted with Secure Enclaves is enabled, provided the other requirements are met as described [here](../../connect/php/always-encrypted-secure-enclaves.md).|Disabled|
|ConnectionPooling|1 or **true** for connection pooling on.
0 or **false** for connection pooling off.|Specifies whether the connection is assigned from a connection pool (1 or **true**) or not (0 or **false**).1|**true** (1)|
|ConnectRetryCount|Integer between 0 and 255 (inclusive)|The maximum number of attempts to reestablish a broken connection before giving up. By default, a single attempt is made to reestablish a connection when broken. A value of 0 means that no reconnection will be attempted.|1|
|ConnectRetryInterval|Integer between 1 and 60 (inclusive)|The time, in seconds, between attempts to reestablish a connection. The application will attempt to reconnect immediately upon detecting a broken connection, and will then wait `ConnectRetryInterval` seconds before trying again. This keyword is ignored if `ConnectRetryCount` is equal to 0.|1|
|Database|String|Specifies the name of the database in use for the connection being established2.|The default database for the login being used.|
|DecimalPlaces
(not supported in the PDO_SQLSRV driver)|Integer between 0 and 4 (inclusive)|Specifies the decimal places when formatting fetched money values.
This option works only when `FormatDecimals` is true. Any negative integer or value more than 4 will be ignored.|Default precision and scale|
|Driver|String|Specifies the Microsoft ODBC driver used to communicate with SQL Server.
Possible values are:
ODBC Driver 17 for SQL Server
ODBC Driver 13 for SQL Server
ODBC Driver 11 for SQL Server (Windows only).|When the Driver keyword is not specified, the Microsoft Drivers for PHP for SQL Server attempt to find supported Microsoft ODBC driver(s) in the system, starting with the latest version of ODBC and so on.|
|Encrypt|1 or **true** for encryption on.
0 or **false** for encryption off.|Specifies whether the communication with SQL Server is encrypted (1 or **true**) or unencrypted (0 or **false**)3.|**false** (0)|
|Failover_Partner|String|Specifies the server and instance of the database's mirror (if enabled and configured) to use when the primary server is unavailable.
There are restrictions to using `Failover_Partner` with `MultiSubnetFailover`. For more information, see [Support for High Availability, Disaster Recovery](../../connect/php/php-driver-for-sql-server-support-for-high-availability-disaster-recovery.md).
This option is not supported on Linux or macOS because database mirroring is not supported by the ODBC driver on Linux or macOS. Instead, use Always On availability groups and set the `MultiSubnetFailover` and `TransparentNetworkIPResolution` options.|Not set.|
|FormatDecimals
(not supported in the PDO_SQLSRV driver)|1 or **true** to format fetched decimal strings.
0 or **false** for default decimal formatting behavior.|Specifies whether to add leading zeroes to decimal strings when appropriate and enables the `DecimalPlaces` option for formatting money types. If left false, the default behavior of returning exact precision and omitting leading zeroes for values less than 1 is used.
For more information, see [Formatting Decimal Strings and Money Values](../../connect/php/formatting-decimals-sqlsrv-driver.md).|**false** (0)|
|KeyStoreAuthentication|**KeyVaultPassword**
**KeyVaultClientSecret**|Authentication method for accessing Azure Key Vault. Controls what kind of credentials are used with `KeyStorePrincipalId` and `KeyStoreSecret`. For more information, see [Using Azure Key Vault](../../connect/php/using-always-encrypted-php-drivers.md#using-azure-key-vault).|Not set.|
|KeyStorePrincipalId|String|Identifier for the account seeking to access Azure Key Vault.
If `KeyStoreAuthentication` is **KeyVaultPassword**, this must be an Azure Active Directory username.
If `KeyStoreAuthentication` is **KeyVaultClientSecret**, this must be an application client ID.|Not set.|
|KeyStoreSecret|String|Credential secret for the account seeking to access Azure Key Vault.
If `KeyStoreAuthentication` is **KeyVaultPassword**, this must be an Azure Active Directory password.
If `KeyStoreAuthentication` is **KeyVaultClientSecret**, this must be an application client secret.|Not set.|
|Language|String|Specifies the language of messages returned by the server. The available languages are listed in the `sys.syslanguages` table.
This option does not affect the language used by the drivers themselves, as they are currently available only in English, and it does not affect the language of the underlying ODBC driver, whose language is determined by the localized version installed on the client system. Therefore, changing this setting may result in messages being returned in different languages, depending on whether they come from the PHP driver, the ODBC driver, or SQL Server.|The default is the language set in SQL Server.|
|LoginTimeout|Integer (SQLSRV driver)
String (PDO_SQLSRV driver)|Specifies the number of seconds to wait before failing the connection attempt.|No timeout.|
|MultipleActiveResultSets|1 or **true** to use multiple active result sets.
0 or **false** to disable multiple active result sets.|Disables or explicitly enables support for multiple active result sets (MARS).
For more information, see [How to: Disable Multiple Active Resultsets (MARS)](../../connect/php/how-to-disable-multiple-active-resultsets-mars.md).|true (1)|
|MultiSubnetFailover|String|Always specify `multiSubnetFailover=yes` when connecting to the availability group listener of a [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)] availability group or a [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)] Failover Cluster Instance. `multiSubnetFailover=yes` configures [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] to provide faster detection of and connection to the (currently) active server. Possible values are Yes and No.
For more information about [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] support for [!INCLUDE[ssHADR](../../includes/sshadr_md.md)], see [Support for High Availability, Disaster Recovery](../../connect/php/php-driver-for-sql-server-support-for-high-availability-disaster-recovery.md).|No|
|PWD
(not supported in the PDO_SQLSRV driver)|String|Specifies the password associated with the User ID to be used when connecting with SQL Server Authentication4.|Not set.|
|QuotedId|1 or **true** to use SQL-92 rules.
0 or **false** to use legacy rules.|Specifies whether to use SQL-92 rules for quoted identifiers (1 or **true**) or to use legacy Transact-SQL rules (0 or **false**).|**true** (1)|
|ReturnDatesAsStrings
(not supported in the PDO_SQLSRV driver)|1 or **true** to return date and time types as strings.
0 or **false** to return date and time types as PHP **DateTime** types.|Retrieves date and time types (datetime, smalldatetime, date, time, datetime2, and datetimeoffset) as strings or as PHP types. For more information, see [How to: Retrieve Date and Time Types as Strings Using the SQLSRV Driver](../../connect/php/how-to-retrieve-date-and-time-type-as-strings-using-the-sqlsrv-driver.md).
When using the PDO_SQLSRV driver, dates are returned as strings unless otherwise specified. For more information, see [How to: Retrieve Date and Time Types as PHP DateTime Objects Using the PDO_SQLSRV Driver](../../connect/php/how-to-retrieve-datetime-objects-using-pdo-sqlsrv-driver.md).|**false**|
|Scrollable|String|"buffered" indicates that you want a client-side (buffered) cursor, which allows you to cache an entire result set in memory. For more information, see [Cursor Types (SQLSRV Driver)](../../connect/php/cursor-types-sqlsrv-driver.md).|Forward-only cursor|
|Server
(not supported in the SQLSRV driver)|String|The [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance to connect to.
You can also specify a virtual network name, to connect to an AlwaysOn availability group. For more information about [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] support for [!INCLUDE[ssHADR](../../includes/sshadr_md.md)], see [Support for High Availability, Disaster Recovery](../../connect/php/php-driver-for-sql-server-support-for-high-availability-disaster-recovery.md).|Server is a required keyword (although it does not have to be the first keyword in the connection string). If a server name is not passed to the keyword, an attempt is made to connect to the local instance.
The value passed to Server can be the name of a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance, or the IP address of the instance. You can optionally specify a port number (for example, `sqlsrv:server=(local),1033`).
Beginning in version 3.0 of the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] you can also specify a LocalDB instance with `server=(localdb)\instancename`. For more information, see [Support for LocalDB](../../connect/php/php-driver-for-sql-server-support-for-localdb.md).|
|TraceFile|String|Specifies the path for the file used for trace data.|Not set.|
|TraceOn|1 or **true** to enable tracing.
0 or **false** to disable tracing.|Specifies whether ODBC tracing is enabled (1 or **true**) or disabled (0 or **false**) for the connection being established.|**false** (0)|
|TransactionIsolation|The SQLSRV driver uses the following values:
SQLSRV_TXN_READ_UNCOMMITTED
SQLSRV_TXN_READ_COMMITTED
SQLSRV_TXN_REPEATABLE_READ
SQLSRV_TXN_SNAPSHOT
SQLSRV_TXN_SERIALIZABLE
The PDO_SQLSRV driver uses the following values:
PDO::SQLSRV_TXN_READ_UNCOMMITTED
PDO::SQLSRV_TXN_READ_COMMITTED
PDO::SQLSRV_TXN_REPEATABLE_READ
PDO::SQLSRV_TXN_SNAPSHOT
PDO::SQLSRV_TXN_SERIALIZABLE|Specifies the transaction isolation level.
For more information about transaction isolation, see [SET TRANSACTION ISOLATION LEVEL](../../t-sql/statements/set-transaction-isolation-level-transact-sql.md) in the SQL Server documentation.|SQLSRV_TXN_READ_COMMITTED
or
PDO::SQLSRV_TXN_READ_COMMITTED|
|TransparentNetworkIPResolution|**Enabled** or **Disabled**|Affects the connection sequence when the first resolved IP of the hostname does not respond and there are multiple IPs associated with the hostname.
It interacts with `MultiSubnetFailover` to provide different connection sequences. For more information, see [Transparent Network IP Resolution](../../connect/php/php-driver-for-sql-server-support-for-high-availability-disaster-recovery.md) or [Using Transparent Network IP Resolution](https://docs.microsoft.com/sql/connect/odbc/using-transparent-network-ip-resolution).|Enabled|
|TrustServerCertificate|1 or **true** to trust certificate.
0 or **false** to not trust certificate.|Specifies whether the client should trust (1 or **true**) or reject (0 or **false**) a self-signed server certificate.|**false** (0)|
|UID
(not supported in the PDO_SQLSRV driver)|String|Specifies the User ID to be used when connecting with SQL Server Authentication4.|Not set.|
|WSID|String|Specifies the name of the computer for tracing.|Not set.|
| | | | |
1. The `ConnectionPooling` attribute cannot be used to enable/disable connection pooling in Linux and Mac. See [Connection Pooling (Microsoft Drivers for PHP for SQL Server)](../../connect/php/connection-pooling-microsoft-drivers-for-php-for-sql-server.md).
2. All queries executed on the established connection are made to the database that is specified by the `Database` attribute. However, if the user has the appropriate permissions, data in other databases can be accessed by using a fully qualified name. For example, if the *master* database is set with the `Database` connection attribute, it is still possible to execute a Transact-SQL query that accesses the *AdventureWorks.HumanResources.Employee* table by using the fully qualified name.
3. Enabling `Encryption` can impact the performance of some applications due to the computational overhead required to encrypt data.
4. The `UID` and `PWD` attributes must both be set when connecting with [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Authentication.
Many of the supported keys are ODBC connection string attributes. For information about ODBC connection strings, see [Using Connection String Keywords with SQL Native Client](../../relational-databases/native-client/applications/using-connection-string-keywords-with-sql-server-native-client.md).
## See Also
[Connecting to the Server](../../connect/php/connecting-to-the-server.md)