如何从PDO连接到SQL-Server(dblib)?

时间:2017-04-04 10:21:11

标签: php sql-server pdo centos

CentOS7。我已经安装了

yum install freetds-bin

yum install php5-mssql

phpinfo中的PDO驱动程序:dblib,mysql,sqlite

带连接的文件:

try {
    $hostname = "xxx.xxx.xxx.xx";
    $port = 1443;
    $dbname = "MyName";
    $username = "test";
    $pw = "123456";
    $dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
}

此页面运行时间很长,最后显示错误500.

此文件中的连接错误?或者是在MSSQL端错误地打开了SQL Server的远程访问?如何理解问题的哪一方?

0 个答案:

没有答案