8

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.

hsuk
  • 6,770
  • 13
  • 50
  • 80
  • 1
    didn't try that myself before, but did you installed the odbc driver required for this extension ? http://www.microsoft.com/en-us/download/details.aspx?id=28160 – Hawili Aug 07 '12 at 05:01
  • odbc driver installation is already done, I just can't figure out how to install sqlsrv driver, even can't figure out whether it can be installed on linux – hsuk Aug 07 '12 at 05:20
  • 2
    http://docs.php.net/manual/en/sqlsrv.requirements.php says it's a windows-only extension. Where did you read otherwise? – VolkerK Aug 07 '12 at 07:14
  • Yeah, I even read those comments but I found the package for linux too.http://pecl.php.net/package/sqlsrv – hsuk Aug 07 '12 at 10:18
  • 4
    I see no indication that the driver at pecl.php.net/package/sqlsrv is for linux. It's the same windows-only package you can download from codeplex. – VolkerK Aug 07 '12 at 10:51
  • Thanks for your concern @VolkerK. I thought the file provided for download has extension capable to install on linux. Anyway, what can be the alternative then ? – hsuk Aug 07 '12 at 11:53
  • Have you looked at FreeTDS? – Benny Hill Feb 05 '13 at 04:48
  • FreeTDS even didn't support UTF-8 – hsuk Feb 05 '13 at 05:06
  • @hsuk have you resolved that problem? I have same disaster with `NVARCHAR ` – Szymon Toda Nov 05 '14 at 15:44

4 Answers4

2

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
Sean Bright
  • 118,630
  • 17
  • 138
  • 146
GardenRouteGold
  • 5,979
  • 2
  • 14
  • 23
1

I Googled a bit more after I read this and I may have found the answer. On Debian:

# apt-get install freetds-common freetds-bin unixodbc php5-mssql

That will install everything PHP needs for Free TDS and allows me to connect using the sqlsrv driver.

user1161625
  • 642
  • 1
  • 8
  • 13
1

Other UTF-8 compatible solution dblib:

  1. You install freetds and use php-mssql driver with PDO.

  2. Change encoding in /etc/freetds.conf

  3. Change charset and date format in /etc/locales.conf

I did it back in 2010.

0

Please change:

echo -e "; priority=20\nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods-   available/pdo_sqlsrv.ini

to:

echo -e "; priority=20\nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods-available/pdo_sqlsrv.ini
sertsedat
  • 3,490
  • 1
  • 25
  • 45