Skip to content

Instantly share code, notes, and snippets.

@piffall
Last active June 11, 2024 21:52
Show Gist options
  • Save piffall/0ac5d30b4dc81cd33953 to your computer and use it in GitHub Desktop.
Save piffall/0ac5d30b4dc81cd33953 to your computer and use it in GitHub Desktop.
MS SQL Server/PHP with FreeTDS (Debian/Ubuntu)

MS SQL Server/PHP with FreeTDS (Debian/Ubuntu)

Install required packages

sudo aptitude install freetds-bin freetds-common tdsodbc odbcinst php5-odbc unixodbc

Edit /etc/odbcinst.ini, and add the following lines

[FreeTDS]
Description=TDS driver (Sybase/MS SQL)
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so

Connect

<?php
$db = new PDO('odbc:Driver=FreeTDS;Server=host;Port=port;Database=database;UID=user;PWD=pass;');
?>

Thanks Pete Donnell!

@yanuck
Copy link

yanuck commented Jun 11, 2024

Thanks for sharing, i was looking for this since hours <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment