本文介绍了MSSQL PDO找不到驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用通过XAMPP和Microsoft SQL Server 2008 R2(SQLEXPRESS)安装的PHP版本5.3.8。我有正确安装的驱动程序(我猜),并添加了正确的行到php.ini(扩展= p​​hp_pdo_sqlsrv_53_ts_vc9.dll准确)。



像这样连接到服务器:

  try {

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

} catch(PDOException $ e){

echo $ e-> getMessage();
}



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



我DL'd我的驱动程序从


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).

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.

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

Any advice would be awesome!!

解决方案

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 ;)

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

这篇关于MSSQL PDO找不到驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-21 04:34