db2 PHP警告:PHP启动:无法加载模块“favicon.ico”

sauutmhj  于 2022-11-07  发布在  DB2
关注(0)|答案(1)|浏览(346)

我想在Windows上安装PHP的db2扩展,但它就是不工作。我已经尝试了很多不同的解决方案,但我仍然得到这些:
php.exe
phpinfo()
When I try connection to db2 database
我在端口80上的XAMPP上使用Apache。我安装了以下内容:https://github.com/ibmdb/php_ibm_db2/tree/master/PHP%207.4.x/x64/TS并将其放在我的C:\xampp\php\ext文件夹中,并在我的php.ini文件中设置“extension=php_ibm_db2.dll”。(该文件位于C:\xampp\php中)
Only "db2" appearing in phpinfo()
Variable where db2 is appearing
PATH variable

ssgvzors

ssgvzors1#

因此,我没有设法用db2扩展连接到我的db2 DB,但我找到了一个替代方法--〉

$database = "xxx";
$hostname = "xxx";
$user     = "xxx";
$password = "xxx";
$port     = 50000;

# Build the connection string

$driver  = "DRIVER={IBM DB2 ODBC DRIVER};";
$dsn     = "DATABASE=$database; " .
           "HOSTNAME=$hostname;" .
           "PORT=$port; " .
           "PROTOCOL=TCPIP; " .
           "UID=$user;" .
           "PWD=$password;";

$conn_string = $driver . $dsn;

# Connect

$conn = odbc_connect( $conn_string, "", "" );
if( $conn )
{
    echo "Connection succeeded.";
    odbc_close( $conn );
}
else
{
    echo "Connection failed.";
}

output --〉连接成功。
源代码--〉https://www.ibm.com/docs/en/db2woc?topic=programmatically-php

相关问题