MSSQL PDO找不到驱动程序

时间:2022-09-19 14:41:55

I'm using PHP Version 5.3.8 that was installed via XAMPP along with Microsoft SQL Server 2008 R2 (SQLEXPRESS). I have the drivers installed correctly (i guess) and have added the correct line into php.ini (extension=php_pdo_sqlsrv_53_ts_vc9.dll to be exact).

我使用的是通过XAMPP和Microsoft SQL Server 2008 R2 (SQLEXPRESS)安装的PHP 5.3.8版本。我已经正确安装了驱动程序(我猜),并将正确的行添加到php中。ini(扩展= php_pdo_sqlsrv_53_ts_vc9。确切地说是dll)。

I'm trying to connect to the server like so:

我试着像这样连接到服务器:

try {

    $DBH = new PDO("mssql:host=xxxx;dbname=xxxx", 'xxxx', 'xxxx');

} catch(PDOException $e) {

    echo $e->getMessage();
}

I get the "could not find driver" error, and I've tweaked it all kinds of ways to solve the problem. I've tried all other kinds of drivers, but this is the only one that Apache doesn't give me an error on startup. When I run phpinfo(), the pdo_sqlsrv fields are all blank except pdo_sqlsrv.log_severity which is set to 0.

我得到了“找不到驱动程序”的错误,我调整了各种方法来解决这个问题。我尝试过所有其他类型的驱动程序,但是这是Apache在启动时唯一没有给我错误的驱动程序。当我运行phpinfo()时,pdo_sqlsrv字段都是空的,除了pdo_sqlsrv。log_severity被设置为0。

I DL'd my drivers from microsoft, and I've tried both 2.0 and 3.0

我从微软下载了我的驱动程序,我尝试了2.0和3.0

Any advice would be awesome!!

任何建议都太棒了!!

2 个解决方案

#1


6  

mssql is the old way of doing it, sqlsrv should be more appropriate! In fact the extension is called (extension=php_pdo_sqlsrv_53_ts_vc9.dll) as well ;)

mssql是旧的方法,sqlsrv应该更合适!实际上,这个扩展也被调用(extension=php_pdo_sqlsrv_53_ts_vc9.dll);

try {

    $DBH = new PDO("sqlsrv:Server=xxxx;Database=xxxx", 'xxxx', 'xxxx');

} catch (PDOException $e) {

    echo $e->getMessage();
}

Hope this helps!

希望这可以帮助!

Source : http://php.net/manual/fr/ref.pdo-sqlsrv.connection.php

来源:http://php.net/manual/fr/ref.pdo-sqlsrv.connection.php

MSSQL PDO找不到驱动程序

#2


2  

Not sure if this is due to running a CentOS x86_64 machine but sqlsrv didn't work as the driver for me, I had to use dblib:

我不确定这是否是因为运行了CentOS x86_64机器,但是sqlsrv并不是我的驱动程序,我必须使用dblib:

try {

    $DBH = new PDO("dblib:host=xxxx;dbname=xxxx", 'xxxx', 'xxxx');

} catch (PDOException $e) {

    echo $e->getMessage();
}

Source and thanks to: http://grover.open2space.com/content/use-php-and-pdo-connect-ms-sql-server

来源和感谢:http://grover.open2space.com/content/use-php-and-pdo- connectms -sql-server

#1


6  

mssql is the old way of doing it, sqlsrv should be more appropriate! In fact the extension is called (extension=php_pdo_sqlsrv_53_ts_vc9.dll) as well ;)

mssql是旧的方法,sqlsrv应该更合适!实际上,这个扩展也被调用(extension=php_pdo_sqlsrv_53_ts_vc9.dll);

try {

    $DBH = new PDO("sqlsrv:Server=xxxx;Database=xxxx", 'xxxx', 'xxxx');

} catch (PDOException $e) {

    echo $e->getMessage();
}

Hope this helps!

希望这可以帮助!

Source : http://php.net/manual/fr/ref.pdo-sqlsrv.connection.php

来源:http://php.net/manual/fr/ref.pdo-sqlsrv.connection.php

MSSQL PDO找不到驱动程序

#2


2  

Not sure if this is due to running a CentOS x86_64 machine but sqlsrv didn't work as the driver for me, I had to use dblib:

我不确定这是否是因为运行了CentOS x86_64机器,但是sqlsrv并不是我的驱动程序,我必须使用dblib:

try {

    $DBH = new PDO("dblib:host=xxxx;dbname=xxxx", 'xxxx', 'xxxx');

} catch (PDOException $e) {

    echo $e->getMessage();
}

Source and thanks to: http://grover.open2space.com/content/use-php-and-pdo-connect-ms-sql-server

来源和感谢:http://grover.open2space.com/content/use-php-and-pdo- connectms -sql-server