Install SQLSRV driver on Linux, or other UTF-8 capable driver?

hsuk picture hsuk · Aug 7, 2012 · Viewed 31.8k times · Source

SQLSRV is the only driver for PHP that is capable of storing UTF-8 strings into two-byte columns (NVARCHAR instead of VARCHAR) which is currently maintained and supported by Microsoft for PHP 5.2.X and 5.3.X.

And I also got the link for downloading these drivers Linux SQLSRV driver download for linux but I could not configure.

If someone has got idea how to configure the sqlsrv driver on linux or has some other alternative to retrieve the data from SQL server in UTF-8 format, please share.

Answer

GardenRouteGold picture GardenRouteGold · Nov 1, 2016

Here's a wiki post from the Microsoft Community

https://github.com/Microsoft/msphpsql/wiki/Install-pdo_sqlsrv-for-PHP-7.0-on-Debian

I think the easiest route would be the php-pear route

# (1) Install PDO driver from pecl
apt-get install unixodbc-dev php7.0-dev php-pear
pecl install pdo_sqlsrv-4.0.5
echo -e "; priority=20\nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods-available/pdo_sqlsrv.ini
phpenmod -v 7.0 pdo_sqlsrv