Connect phpGrid to MS SQL Server in Linux

When connecting phpGrid to SQL Server in Linux, it's common to receive a warning similar to the following:

Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect.

To access MSSQL from *nix, install FreeTDS and unixODBC, 

sudo apt-get unixodbc unixodbc-dev freetds-dev tdsodbc
then configurate freetds.conf, odbc.ini and odbcinst.ini 

--- /etc/odbc.ini ---
Description = "test"
Driver = FreeTDS
Port = 1433
Database = DBNAME

--- /etc/odbcinst.ini ---
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/

--- /etc/freetds/freetds.conf ---
port = 1433
tds version = 7.0
client charset = UTF-8

Finally, add setting to the server environment in conf.php.

// conf.php putenv("ODBCINSTINI=/usr/local/Cellar/unixodbc/2.3.1/etc/odbcinst.ini"); putenv("ODBCINI=/usr/local/Cellar/unixodbc/2.3.1/etc/odbc.ini");

Feedback and Knowledge Base