v5:database:microsoft_sql_server
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
database:microsoft_sql_server [2015/11/28 00:11] – mnewnham | v5:database:microsoft_sql_server [2022/11/15 02:13] (current) – [Common Connection Problems] mnewnham | ||
---|---|---|---|
Line 2: | Line 2: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
===== Description ===== | ===== Description ===== | ||
- | There are 2 supported drivers that allow connections to Microsoft SQL Server databases. | + | There are 2 supported drivers that allow connections to Microsoft SQL Server databases |
- | ==== SQL Server 2003 ==== | + | ==== mssqlnative |
- | Connecting to SQL server 2003 creates a difficulty There is no support for native client | + | This driver, which runs on both Windows and Linux clients, |
- | ------------------------------------ | + | |
+ | More about the Microsoft SQL Server client for Linux [[https:// | ||
+ | |||
+ | ==== mssql==== | ||
+ | This allows | ||
+ | |||
+ | More about the FreeTDS | ||
====== mssqlnative ====== | ====== mssqlnative ====== | ||
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
Line 13: | Line 20: | ||
^Status|Active((This driver is actively supported by ADOdb project members))| | ^Status|Active((This driver is actively supported by ADOdb project members))| | ||
^Windows|Yes| | ^Windows|Yes| | ||
- | ^Unix|No| | + | ^Unix|Yes| |
^ADOdb V5|Yes| | ^ADOdb V5|Yes| | ||
^ADOdb V6|Yes| | ^ADOdb V6|Yes| | ||
== Alternatives == | == Alternatives == | ||
- | [[database: | + | [[v5:database: |
+ | [[v5: | ||
+ | == See Also == | ||
+ | [[v5: | ||
</ | </ | ||
- | **This is the preferred driver for connecting to a SQL server database from Windows clients.** | + | **This is the preferred driver for connecting to a SQL server database from both Windows |
- | This driver was contributed by Microsoft and provides connections to SQL server databases greater than version 2000. It requires PHP version 5.3 or greater, Microsoft native client software and the appropriate PHP driver. | + | The original |
+ | * On Windows clients, | ||
+ | * On Linux clients, PHP version 7.0 and higher is required. | ||
Sequences are supported in native mode in SQL Sever 2012, and emulated in earlier versions. | Sequences are supported in native mode in SQL Sever 2012, and emulated in earlier versions. | ||
+ | -------------------------------- | ||
+ | ==== DateTime Fields ==== | ||
+ | The default behavior for the **PHP** mssqlnative driver is to return date/time fields as a PHP [[http:// | ||
+ | |||
+ | [RequiredDate] => DateTime Object | ||
+ | ( | ||
+ | [date] => 1996-08-01 00: | ||
+ | [timezone_type] => 3 | ||
+ | [timezone] => America/ | ||
+ | ) | ||
+ | |||
+ | |||
+ | However, in order to improve portability, | ||
+ | |||
+ | [RequiredDate] => 1996-08-01 00: | ||
+ | |||
+ | In order to return the dateTime as an object, the following action is required: | ||
+ | <code php> | ||
+ | $db = ADONewConnection(' | ||
+ | $db-> | ||
+ | $db-> | ||
+ | </ | ||
+ | |||
+ | ===== Unicode Strings ===== | ||
+ | You can set the character set to UTF-8 using: | ||
+ | <code php> | ||
+ | $db = ADONewConnection(' | ||
+ | $db-> | ||
+ | $db-> | ||
+ | </ | ||
+ | |||
+ | ===== Using Windows Authentication ===== | ||
+ | To use Windows, instead of SQL Server authentication, | ||
+ | <code php> | ||
+ | $db = ADONewConnection(' | ||
+ | $db-> | ||
+ | </ | ||
+ | |||
+ | ===== Common Connection Problems ===== | ||
+ | Recent versions of SQL Server fail to connect with an error '' | ||
+ | |||
+ | This problem can be resolved by adding | ||
+ | |||
+ | <code php> | ||
+ | $db-> | ||
+ | </ | ||
+ | |||
+ | before issuing the '' | ||
- | {{tag> | ||
------------------------------ | ------------------------------ | ||
+ | ===== How to create a connection under Linux ===== | ||
+ | Establishing a connection to a SQL server database from a Linux client can be difficult, but by installing the freetds tools as well as the Microsoft ones provides a highly useful tool, // | ||
+ | |||
+ | In the example, our database is running on a server 192.168.0.65: | ||
+ | < | ||
+ | # tsql -LH 192.168.0.65 | ||
+ | ServerName STUDY | ||
+ | | ||
+ | IsClustered No | ||
+ | Version 12.0.2000.8 | ||
+ | tcp 55644 | ||
+ | np \\STUDY\pipe\MSSQL$SQLEXPRESS\sql\query | ||
+ | </ | ||
+ | The response from the command tells us the | ||
+ | * The SQL server instance is visible from the client | ||
+ | * the service is running on port 55644 | ||
+ | |||
+ | We can now create a connection string: | ||
+ | |||
+ | <code php> | ||
+ | $db = ADONewConnection(' | ||
+ | $db-> | ||
+ | </ | ||
+ | -------------------------------------- | ||
- | ====== mssql (Unix) | + | ===== mssql (Unix) ===== |
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
== Specification == | == Specification == | ||
Line 41: | Line 124: | ||
^ADOdb V6|Yes| | ^ADOdb V6|Yes| | ||
== Alternatives == | == Alternatives == | ||
- | [[database: | + | [[v5:database: |
</ | </ | ||
- | **This is the preferred driver for connecting to a SQL server database from Linux/Unix clients.** | + | **This is the preferred driver for connecting to a SQL server database from Linux/Unix clients, when the PHP version is less than 7.0** |
This driver provides access to Microsoft SQL Server databases from unix systems via Freetds | This driver provides access to Microsoft SQL Server databases from unix systems via Freetds | ||
- | {{tag> | + | {{tag> |
-------------------------------------- | -------------------------------------- | ||
- | ====== mssql (Windows) | + | ===== mssql (Windows) ===== |
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
== Specification == | == Specification == | ||
Line 62: | Line 145: | ||
This driver was the primary connection method to SQL Server databases up to PHP Version 5.2. The windows dll associated with this driver (php_mssql.dll) was removed from the standard PHP distribution in PHP Version 5.3. There is no community support for this driver. | This driver was the primary connection method to SQL Server databases up to PHP Version 5.2. The windows dll associated with this driver (php_mssql.dll) was removed from the standard PHP distribution in PHP Version 5.3. There is no community support for this driver. | ||
- | {{tag> | + | |
---------------------------------------------------- | ---------------------------------------------------- | ||
- | ====== mssqlpo | + | ===== mssqlpo ===== |
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
== Specification == | == Specification == | ||
Line 79: | Line 162: | ||
{{tag> | {{tag> | ||
- | ====== mssql_n | + | ===== mssql_n ===== |
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
== Specification == | == Specification == | ||
Line 90: | Line 173: | ||
^ADOdb V6|Yes| | ^ADOdb V6|Yes| | ||
</ | </ | ||
- | This driver appears to provide Unicode enhancements to the mssql driver | + | This driver appears to provide Unicode enhancements to the mssql driver. You can set character sets using the [[v5: |
- | {{tag>[SQL_Server unix unicode | + | {{tag>[" |
v5/database/microsoft_sql_server.1448665872.txt.gz · Last modified: 2017/04/21 11:25 (external edit)