2017-02-14 18:31

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

if ($conn) {
    $qry = $conn->query($sql);
    if ($qry) {
        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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • drd0833 drd0833 4年前

    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.

    点赞 评论 复制链接分享
  • dongzhuner6981 dongzhuner6981 4年前

    Are you using the unixODBC or ibm_db2 ( It it recommended to use IBM DB2 Universal Database with “ibm_db2” extension. It’s faster and more efficient than using generic driver. It calls the native IBM DB2 functions with the extension.

    Check out the db2_* functions from IBM DB2 functions manual

    点赞 评论 复制链接分享