PHP スクリプトから ibm_db2 ドライバーを使用して AS/400 V7R2 を実行しています。
接続文字列の残りの部分が有効なオプションを使用しdb2_connect()
て、無効なライブラリ リストを に渡すと、 によってエラーが報告されているにもかかわらず、リソース ID が返されることに気付きました。また、何も含んでいません。反対に、有効なライブラリ リストを提供すると、ステートメントはまったく同じ方法で評価されます。唯一の違いは、エラーが画面に出力されないことです。i5_libl
ini_set("display_errors", 1);
db2_conn_error()
db2_conn_errormsg()
IF
ini_set("display_errors", 1);
無効なライブラリ リストが原因で失敗するのではなく、提供された DB ユーザー名のデフォルトのライブラリ リストを使用して接続していることに気付きました。なんらかの理由でライブラリ リストが無効な場合、デフォルトで間違ったリストになるため、これは私にとって恐ろしいことです (主な懸念事項は、開発環境と運用環境が混在していることです)。
他の誰かがこの動作を再現できますか? これが私のシステムだけで PTF が必要なのか、それとも典型的なものなのかはわかりません。DB2 接続が意図したオプションで確立されたことをどのように確認しますか?
再現するコード (システム名、ユーザー名、パスワードは適宜置き換えてください):
<?php
ini_set("display_errors", 1);
$systemName = 'yourSystemName';
$userID = 'yourUserID';
$password = 'yourPassword';
$options['i5_libl'] = implode('Z', array(
'INVALID',
'LIB',
'LIST',
'IMPLODED',
'WITH',
'THE',
'LETTER',
'Z'
));
$options['i5_naming'] = DB2_I5_NAMING_ON;
$conn = db2_connect($systemName,$userID,$password,$options);
//The error output to the screen at this point from `ini_set("display_errors", 1);` is:
//Warning: db2_connect(): Statement Execute Failed in /PATH/TO/FILE/test.php on line 58
echo "<br />|".db2_conn_error()." ||| ".db2_conn_errormsg()."|<br />"; //This displays as "| ||| |"
print_r($conn); //This prints out a resource ID
echo "<br />";
if(isset($conn) && $conn === true){
//Expected to not pass since either false or a resource ID is supposed to be returned.
//Evaluated to false.
echo "Boolean true<br />";
}
if(isset($conn) && $conn == true){
//Despite the connection failing according to `ini_set("display_errors", 1)` and a resource ID being reportedly returned
//this evaluates to true and "Non-Boolean true 2" echos out to the screen.
echo "Non-Boolean true 2<br />";
}
if(isset($conn) && $conn == "true"){
//Evaluates to false. db2_connect() returns a resource ID on success, so I did not expect this to evaluate to true.
echo "String true";
}
if(isset($conn) && $conn === false){
//Expected for this to evaluate to true since an error was logged by ini_set("display_errors", 1)
//This did not evaluate to true.
echo "Boolean false<br />";
}
if(isset($conn) && $conn == false){
//Just checking to see if a non-Boolean false was returned. Evaluates to false.
echo "Non-Boolean false 2<br />";
}
if(isset($conn) && $conn == "false"){
//Just checking to see if the string "false" was returned. Evaluates to false.
echo "String false";
}
?>