1
    $connection = db2_connect ( '*LOCAL', PHP_USER_NAME, PHP_USER_PASS );
    if (! $connection) {
        die('Could not connect');
    }

    //Prepare and execute the SQL statement.
    $stmt = db2_prepare ( $connection, $sqlStatement );

    if (! db2_execute ( $stmt ) ) {
        Throw New Exception('Could not execute statement');
    }

我们在带有 Apache 的 IBM iSeries 上运行 PHP。我们的数据库也在这个 iSeries 上。

正在建立什么样的连接?它是 ODBC 链接吗?如果这因系统而异,我怎么知道?

4

1 回答 1

1

似乎这是一个ODBC连接:

尝试db2_client_info在您的客户端上运行该功能,这应该会输出所需的信息。您可以运行以下代码:

<?php
$conn = db2_connect( '*LOCAL', PHP_USER_NAME, PHP_USER_PASS );
$client = db2_client_info( $conn );

if ($client) {
    echo "DRIVER_NAME: ";           var_dump( $client->DRIVER_NAME );
    echo "DRIVER_VER: ";            var_dump( $client->DRIVER_VER );
    echo "DATA_SOURCE_NAME: ";      var_dump( $client->DATA_SOURCE_NAME );
    echo "DRIVER_ODBC_VER: ";       var_dump( $client->DRIVER_ODBC_VER );
    echo "ODBC_VER: ";              var_dump( $client->ODBC_VER );
    echo "ODBC_SQL_CONFORMANCE: ";  var_dump( $client->ODBC_SQL_CONFORMANCE );
    echo "APPL_CODEPAGE: ";         var_dump( $client->APPL_CODEPAGE );
    echo "CONN_CODEPAGE: ";         var_dump( $client->CONN_CODEPAGE );
}
else {
    echo "Error retrieving client information.
     Perhaps your database connection was invalid.";
}
db2_close($conn);

?>
于 2012-08-20T17:03:57.200 回答