How to connect MSSQL from PHP 7, Plesk 12.5 instal

2019-09-12 04:50发布

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条回答
劳资没心,怎么记你
2楼-- · 2019-09-12 05:21

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();
查看更多
登录 后发表回答