宝塔用户_mxjzpr 发表于 2026-1-6 09:09:41

【已解答】php连sqlserver2008r2连接不上,是php扩展不兼容的...

为了能快速了解并处理您的问题,请提供以下基础信息:面板、插件版本:
宝塔面板9.2.0
系统版本:
服务器centos stream9。nginx是1.22.1。我php8.3
问题描述:
使用的thinkphp8,要连接的数据库是sqlserver2008r2。我使用宝塔官方扩展,安装pdo-sqlsrv.   提示pdo连接不上。phpinfo显示sqlsrv版本5.11.1。但是微软官网显示5.11可能不支持8.3。不知是不是这个问题引起的。后来,我把php版本切换成8.2和8.1,服务器也重启了,问题和报错还是一样的。现在不知问题在哪
相关截图(日志、错误):
报错如下:SQLSTATE: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712。php中的测试语句为:
try {
Db::connect('aa')->query('SELECT 1');
    echo 'sucess';
} catch (\Exception $e) {
    var_dump("error");
    echo$e->getMessage();
}


阿珂 发表于 2026-1-6 11:05:23

缺少odbc驱动
参考https://learn.microsoft.com/zh-cn/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver17&tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline
页: [1]
查看完整版本: 【已解答】php连sqlserver2008r2连接不上,是php扩展不兼容的...