doudou1438 2017-02-14 18:31
浏览 192
已采纳

PHP 5.6.x失去了连接ODBC源的能力

I have a strange problem. My server has been running PHP 5.6 for years no problem. (WinServer Std 2K8 SP2, IIS 6, MySQL 5.6 {separate server}, PHP 5.6)

We connect it to a DB2 server at our parent company. Today (2017-02-14) the ODBC connection (PDO_ODBC) started returning "could not find driver".

Excel is able to use the same ODBC connection to query the database - the ODBC connection is working.

I tried using both the PDO method and procedural method to connect. Failures in seeing the driver both ways.

From phpinfo(): ODBC Data PDO Data

Code snippet:

$dsn = "odbc:workingODBCdsn";
$user = "xxxx";
$password = "yyyy";
$conn = null;
$results = array();

try {
    $conn = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    die($e->getMessage());
}

if ($conn) {
    $qry = $conn->query($sql);
    if ($qry) {
        $qry->setFetchMode(PDO::FETCH_ASSOC); 
        foreach ($qry as $row) {
            $results[] = $row;
        }
    }
}

print "<pre>" . print_r($results, true) . "</pre>";

//ALT Method
$conn = odbc_connect($dsn, $user, $password);
$results = odbc_exec($conn, $sql);

print "<pre>" . print_r($results, true) . "</pre>";

Thanks in advance for any help.

  • 写回答

2条回答 默认 最新

  • drd0833 2017-02-17 14:45
    关注

    Server's PHP instance switched from IIS to IISExpress. Switching it back to (full) IIS, and enduring all appropriate PDO drivers were enabled fixed the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题