简体   繁体   English

在没有 Microsoft ODBC 库的情况下使用 PHP 连接到 MS SQL 数据库

[英]Connect to a MS SQL database using PHP without Microsoft ODBC libraries

Microsoft has not released yet its library for Ubuntu 22.04 (msodbcsql18). Microsoft 尚未发布其适用于 Ubuntu 22.04 (msodbcsql18) 的库。 So my PHP code does not work anymore:所以我的 PHP 代码不再工作了:

$SERVER = "192.168.2.51";
$DATABASE = "DB_NAME";
$DRIVER = "/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.9.so.1.1";
const USERNAME = "username";
const PASSWORD = "password";

$db = new PDO("odbc:driver=$DRIVER;server=$SERVER;database=$DATABASE", USERNAME, PASSWORD);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

it returns:它返回:

could not find driver找不到驱动程序

I wonder if there is an alternative method to connect to such a database that uses a different library.我想知道是否有另一种方法可以连接到使用不同库的此类数据库。 The DB is a SQL Server 19.数据库是 SQL Server 19。

You can manually download and install the deb file from here .您可以从此处手动下载并安装 deb 文件。

It appears to be working for me so far, YMMV.到目前为止,它似乎对我有用,YMMV。

As an alternative we were previously using the old pdo_dblib driver with success.作为替代方案,我们之前成功地使用了旧的pdo_dblib驱动程序。

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

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