库列表未用于与 IBM i 的远程 PHP DB2 连接
Library List is not being used in remote PHP DB2 connection to IBM i
我已经通过 PHP 从本地 Windows PC 成功连接到远程 IBM i DB2 数据库 (AS400)。我将 IBM 数据服务器客户端与 PHP 中的 db2_*
函数结合使用。我遇到的问题是,尽管我的库列表设置正确,但它没有被用于不合格的 table 名称。相反,它使用当前用户名作为库。但是,当我限定 table 名称时,一切都非常有效。
我已经确认,当我通过查询 QSYS2.LIBRARY_LIST_INFO
创建连接时,我的图书馆列表确实发生了变化。
$database = '<database name>';
$user = '<user name>';
$password = '<password';
$port = <port>;
$options['i5_naming'] = DB2_I5_NAMING_ON;
$options['autocommit'] = DB2_AUTOCOMMIT_OFF;
$options['i5_libl'] = 'MYLIB YOURLIB ANYLIB';
$conn = db2_connect($database, $user, $password, $options);
if ($conn) {
echo "Connection succeeded."; //It succeeds
}
else {
echo db2_conn_error()." | ".db2_conn_errormsg()."<br />";
echo "Connection failed.";
}
$sql = "SELECT * FROM QSYS2.LIBRARY_LIST_INFO";
//Works and proves my library list reflects
//what I passed in when creating the connection.
//$sql = "SELECT * FROM LIBRARY_LIST_INFO";
//Generates: "42S02 : [IBM][CLI Driver][AS] SQL0204N "<user name>.LIBRARY_LIST_INFO" is an undefined name. SQLSTATE=42704 SQLCODE=-204"
//where <user name> is the username used to connect to the DB.
//It should be using the library list specified when creating the connection though.
//This holds true for any table from any library including those specified
//when creating the connection (which includes QSYS2).
$stmt = db2_prepare($conn, $sql);
$result = db2_execute($stmt);
if($result){
while($row = db2_fetch_assoc($stmt)){
echo "<pre>";
var_dump($row); //In addition to entries for QSYS, QSYS2, QUSRSYS and QHLPSYS I get entries for MYLIB, YOURLIB and ANYLIB.
echo "</pre>";
}
}else{
echo "failed<br />";
echo db2_stmt_error()." : ".db2_stmt_errormsg()."<br />";
}
有没有人在连接到远程 DB2 服务器时启用 i5_naming 时 运行 参与其中?我不太确定为什么它不会使用我的库列表,因为 PHP 手册在启用时声明 "Unqualified files are resolved using the library list for the job."。 http://php.net/manual/en/function.db2-connect.php
在IBM开PMR后终于解决了这个问题。我所要做的就是为 DB2 Connect 个人版应用最新的 Fix Pack。
建议的 DB2 Connect 修复包:
http://www-01.ibm.com/support/docview.wss?rs=71&uid=swg21321001
基本上,我使用的 DB2 Connect 版本是在 2013 年之前发布的。IBM 在 2013 年通过添加 i5_naming
选项添加了两层支持。所以我的 DB2 Connect 设置实际上忽略了我传递的选项。所以这就解释了为什么其他选项仍然通过。在数据库方面,因为它没有收到 i5_naming
的值 - 它仍然是默认值。
我已经通过 PHP 从本地 Windows PC 成功连接到远程 IBM i DB2 数据库 (AS400)。我将 IBM 数据服务器客户端与 PHP 中的 db2_*
函数结合使用。我遇到的问题是,尽管我的库列表设置正确,但它没有被用于不合格的 table 名称。相反,它使用当前用户名作为库。但是,当我限定 table 名称时,一切都非常有效。
我已经确认,当我通过查询 QSYS2.LIBRARY_LIST_INFO
创建连接时,我的图书馆列表确实发生了变化。
$database = '<database name>';
$user = '<user name>';
$password = '<password';
$port = <port>;
$options['i5_naming'] = DB2_I5_NAMING_ON;
$options['autocommit'] = DB2_AUTOCOMMIT_OFF;
$options['i5_libl'] = 'MYLIB YOURLIB ANYLIB';
$conn = db2_connect($database, $user, $password, $options);
if ($conn) {
echo "Connection succeeded."; //It succeeds
}
else {
echo db2_conn_error()." | ".db2_conn_errormsg()."<br />";
echo "Connection failed.";
}
$sql = "SELECT * FROM QSYS2.LIBRARY_LIST_INFO";
//Works and proves my library list reflects
//what I passed in when creating the connection.
//$sql = "SELECT * FROM LIBRARY_LIST_INFO";
//Generates: "42S02 : [IBM][CLI Driver][AS] SQL0204N "<user name>.LIBRARY_LIST_INFO" is an undefined name. SQLSTATE=42704 SQLCODE=-204"
//where <user name> is the username used to connect to the DB.
//It should be using the library list specified when creating the connection though.
//This holds true for any table from any library including those specified
//when creating the connection (which includes QSYS2).
$stmt = db2_prepare($conn, $sql);
$result = db2_execute($stmt);
if($result){
while($row = db2_fetch_assoc($stmt)){
echo "<pre>";
var_dump($row); //In addition to entries for QSYS, QSYS2, QUSRSYS and QHLPSYS I get entries for MYLIB, YOURLIB and ANYLIB.
echo "</pre>";
}
}else{
echo "failed<br />";
echo db2_stmt_error()." : ".db2_stmt_errormsg()."<br />";
}
有没有人在连接到远程 DB2 服务器时启用 i5_naming 时 运行 参与其中?我不太确定为什么它不会使用我的库列表,因为 PHP 手册在启用时声明 "Unqualified files are resolved using the library list for the job."。 http://php.net/manual/en/function.db2-connect.php
在IBM开PMR后终于解决了这个问题。我所要做的就是为 DB2 Connect 个人版应用最新的 Fix Pack。
建议的 DB2 Connect 修复包:
http://www-01.ibm.com/support/docview.wss?rs=71&uid=swg21321001
基本上,我使用的 DB2 Connect 版本是在 2013 年之前发布的。IBM 在 2013 年通过添加 i5_naming
选项添加了两层支持。所以我的 DB2 Connect 设置实际上忽略了我传递的选项。所以这就解释了为什么其他选项仍然通过。在数据库方面,因为它没有收到 i5_naming
的值 - 它仍然是默认值。