简体   繁体   English

PHP连接到MSSQL

[英]PHP Connect to MSSQL

I'm trying to connect Microsoft SQL Server 我正在尝试连接Microsoft SQL Server

with (PHP 5.6.36): 与(PHP 5.6.36):

$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");

And i get exception : 我得到例外:

"could not find driver" “找不到驱动程序”

Picture of phpinfo() : phpinfo()图片:

在此处输入图片说明

I searched all over for solutions,but I Couldn't find any post that helped me 我到处搜寻解决方案,但找不到任何对我有帮助的文章

you'll need to install PDO drivers for SQL Server: 您需要为SQL Server安装PDO驱动程序:

http://php.net/manual/en/ref.pdo-sqlsrv.php http://php.net/manual/zh/ref.pdo-sqlsrv.php

Thanks for the help, 谢谢您的帮助,

I used odbc_connect 我用odbc_connect

odbc_connect(
            "DRIVER={ODBC Driver 13 for SQL Server};Server=".$this->hostname.",".$this->port.";Database=".$this->database_name.";MARS_Connection=yes",
            $this->username, $this->password);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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