There is no license information available for the latest version (2.0.3) of this package.

Adds MSSQL support to SilverStripe

Installs: 7 794

Dependents: 0

Suggesters: 0

Security: 0

Stars: 15

Watchers: 12

Forks: 26

Open Issues: 7

Type:silverstripe-vendormodule

2.0.3 2021-01-15 02:53 UTC

This package is auto-updated.

Last update: 2025-06-20 04:52:32 UTC


README

Allows SilverStripe to use SQL Server databases including SQL databases on Azure.

Build status Version License

Requirements

  • SilverStripe 4+
  • SQL Server 2008, 2008 R2, or 2012.

mssql PHP api is no longer supported as of 2.0.

*nix

Linux support is only available via the PDO extension. This requires:

Windows

On windows you can either connect via PDO or sqlsrv. Both options require the SQL Server Driver for PHP. "sqlsrv" 3.0+

Note: SQL Server Express can also be used which is provided free by Microsoft. However, it has limitations such as 10GB maximum database storage.

Installation

composer require silverstripe/mssql ^2

The following environment variables will need to be set:

SS_DATABASE_CLASS="MSSQLAzureDatabase" # or: `MSSQLDatabase` or `MSSQLPDODatabase`
SS_DATABASE_SERVER=""
SS_DATABASE_NAME=""
SS_DATABASE_USERNAME=""
SS_DATABASE_PASSWORD=""

Note on OSX / Linux machines you will need to install the ODBC drivers and the PHP extension sqlsrv or pdo_sqlsrv

Troubleshooting

Q: SQL Server resides on a remote host (a different machine) and I can't connect to it from mine.

A: Please ensure you have enabled TCP access using SQL Server Configuration Manager and opened firewall ports.

Q: I just installed SQL Server, but it says that it cannot connect

A: Sometimes SQL Server will be installed as a non-default instance name, e.g. "SQLExpress" instead of "MSSQLSERVER" (the default.) If this is the case, you'll need to declare the instance name when setting the server in your PHP database configuration. For example: (local)\SQLExpress. The first part before the slash indicates the server host, or IP address. In this case, (local) indicates localhost, which is the same server PHP is running on. The second part is the SQL Server instance name to connect to.

Q: I'm getting unicode SQL Server errors connecting to SQL Server database (e.g. Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier)

A: If you are using FreeTDS make sure you're using TDS version 8.0 in freetds.conf. If on Windows, ensure you use the SQL Server Driver for PHP and NOT the mssql drivers provided by PHP.

Q: Using FreeTDS I can't connect to my SQL Server database. An error in PHP says the server doesn't exist

A: Make sure you've got an entry in /etc/freetds/freetds.conf that points to your server. For example:

[myserver]
	host = myserver.mydomain.com
	port = 1433
	tds version = 8.0

Then you can use "myserver" (the bit in square brackets above) as the server name when connecting to the database. Note that if you're running Macports, the file is located in /opt/local/etc/freetds/freetds.conf.

Alternatively, if you don't want to keep adding more entries to the freetds.conf to nominate more SQL Server locations, you can instead use the full the host/ip and port combination, such as "myserver:1433" (1433 being the default SQL Server port.) and ensure the "tds version = 8.0" is set globally in the freetds.conf file.

Note: Use tabs not spaces when editing freetds.conf, otherwise it will not load the configuration you have specified!

Note: Certain distributions of Linux use SELinux which could block access to your SQL Server database. A rule may need to be added to allow this traffic through.