使用 PHP 5.1.6 与 IBM DB2 的 ODBC 连接

moo*_*uck 1 php db2 odbc unixodbc ibm-midrange

我正在使用 CentOS 5.6 版(最终版)和 PHP 5.1.6(cli)(构建时间:2012 年 2 月 2 日 18:24:47)。我需要与同一本地网络中的 DB2 数据库服务器连接。db2 版本是 V5R3。我已经安装了 iSeriesAccess 客户端和 unixODBC。

我的 odbc.ini 配置:

[iSeries Access ODBC Driver]
Description             = iSeries Access for Linux ODBC Driver
Driver          = /opt/ibm/iSeriesAccess/lib/libcwbodbc.so
Setup           = /opt/ibm/iSeriesAccess/lib/libcwbodbcs.so
NOTE1           = If using unixODBC 2.2.11 or later and you want the 32 and 64-bit ODBC drivers to share DSN's,
NOTE2           = the following Driver64/Setup64 keywords will provide that support.
Driver64                = /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
Setup64         = /opt/ibm/iSeriesAccess/lib64/libcwbodbcs.so
Threading               = 2
DontDLClose             = 1

UsageCount              = 1
Run Code Online (Sandbox Code Playgroud)

我正在运行以下代码:

<?php
$database = 'dbname';
$server = 'local_ip';
$user = 'username';
$password = 'password';
$driver = 'iSeries Access ODBC Driver';



$conn = odbc_connect("Driver={iSeries Access ODBC Driver};Server=$server;Database=$database;", $user, $password);
if (!$conn......)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息:“ [unixODBC][IBM][System i Access ODBC 驱动程序]缺少连接所需的系统名称。错误!

有什么我想念的吗?欢迎您提出建议。

jam*_*man 5

Server属性应该是System

有关连接字符串关键字常规属性的更多信息,请参见 i5/OS 信息中心 。