1. Home
  2. Technical
  3. PHP
  4. Connecting to MSSQL

Connecting to MSSQL

In order to connect to MSSQL, you need to activate the PDO / DBLib extension under PHP extensions.
To activate PHP extensions, select “Webserver” -> “Main domain settings” and from there select “modify” -> “PHP extensions”.

 

 

 

Via the extensions menu, enable PDO / DBLib.

In order to change the settings for connecting to the MS SQL server, you need to create a new file in the home directory /data0X/virtXXX/ named .freetds.conf,
(NB! the file name starts with a dot) with the following contents for example:

[ODBC]
host = 123.123.123.123
port = 1234
tds version = 8.0
client charset = UTF-8
mssql.charset = "UTF-8"

Sample script for creating an MSSQL connection:

$pdo = new PDO('dblib:host=ODBC;dbname=database_name;', 'user', 'pass');

Details on how to configure .freetds.conf can be found on the FreeTDS website.

Updated on 19. Apr 2024
Was this article helpful?

Related Articles