How to connect MSSQL from PHP 7, Plesk 12.5 installed on CentOS 7

末鹿安然 提交于 2020-01-07 00:36:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!