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 | ||
v5:database:microsoft_sql_server [2018/07/08 01:07] – [mssql] 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 |
==== mssqlnative ==== | ==== mssqlnative ==== | ||
- | This driver, which runs on both Windows and Linux clients, allows connections to Microsoft SQL Server databases versions 2008 and up, and uses the Microsoft Native Client libraries. This driver is now recommended for both Windows and Linux platforms, and provides the fastest PHP connection. | + | This driver, which runs on both Windows and Linux clients, allows connections to Microsoft SQL Server databases versions 2008 and up, and uses the Microsoft Native Client libraries. This driver is recommended for Windows |
More about the Microsoft SQL Server client for Linux [[https:// | More about the Microsoft SQL Server client for Linux [[https:// | ||
Line 12: | Line 12: | ||
More about the FreeTDS libraries [[http:// | More about the FreeTDS libraries [[http:// | ||
- | ==== SQL Server 2003 ==== | + | |
- | Connecting to SQL server 2003 creates a difficulty There is no support for native client connections, | + | |
- | ------------------------------------ | + | |
====== mssqlnative ====== | ====== mssqlnative ====== | ||
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
Line 28: | Line 26: | ||
[[v5: | [[v5: | ||
[[v5: | [[v5: | ||
+ | == See Also == | ||
+ | [[v5: | ||
</ | </ | ||
Line 74: | Line 74: | ||
$db-> | $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 '' | ||
+ | |||
+ | |||
------------------------------ | ------------------------------ | ||
+ | ===== 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) ===== | ||
Line 89: | Line 126: | ||
[[v5: | [[v5: | ||
</ | </ | ||
- | **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) ===== | ||
Line 136: | 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> | {{tag> |
v5/database/microsoft_sql_server.txt · Last modified: 2022/11/15 02:13 by mnewnham