问题
My Plesk 12.5 installed on CentOS 7 and supporting multiple php versions in same time. I have successfully installed pdo_dblib driver for php version 5.4.16. Does anybody knows how to install similar driver for php 7. I have PDO enabled on php7 and support PDO drivers mysql, odbc, pgsql, sqlite. How I can add mssql. I found this links library I need php70w-pdo_dblib but how I can installed? question on the plesk site
回答1:
Thanks everybody for the help. I have resolved my problem by simply connect MSSQL with ODBC diver, which is come together with PHP7 You need to make sure you have
/ etc/odbc.ini
[SomeName]
Description = " SomeName "
Driver = FreeTDS
Trace = No
Servername = TestServer
Database = dbname
UserName = username
Password = pass
[Default]
Driver = /usr/lib64/libtdsS.so.1
/etc/freetds.conf
[TestServer]
host =dbhostname
port = 1433
client charset = UTF-8
tds version = 8.0
And then in php
$db = new PDO("odbc: SomeName ", " username ", " pass");
$sql = " select *…….”
$stmt = $db->prepare($sql);
$stmt->execute();
来源:https://stackoverflow.com/questions/37837068/how-to-connect-mssql-from-php-7-plesk-12-5-installed-on-centos-7