简体   繁体   中英

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

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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM