【发布时间】:2014-02-18 15:10:57
【问题描述】:
我有一个对我在 iSeries 上运行的程序的查询。我了解有时此查询会偶尔填写,因为没有可供选择的记录。每次查询失败时,它都会记录到 php.log 中:
PHP Warning: db2_fetch_assoc(): Fetch Failure in /www/zendsvr6/htdocs/views/hp1110.php on line 82
我正在寻找一种解决方案来防止记录此错误。我知道我已经可以禁用 PHP 错误日志记录了。我不想禁用日志记录。
以下是代码示例:
$stmt = db2_prepare($conn, $sql);
if (!$stmt) {
$code = db2_stmt_error();
$msg = db2_stmt_errormsg();
// TODO in production do not display SQL. Log it instead.
die("Failed to prepare $sql. Reason: $code $msg");
} //(if (!$result))
$bound1 = db2_bind_param($stmt, 1, "item", DB2_PARAM_IN);
$bound2 = db2_bind_param($stmt, 2, "house", DB2_PARAM_IN);
$bound3 = db2_bind_param($stmt, 3, "counter", DB2_PARAM_INOUT);
if (!$bound1 || !$bound2 || !$bound3) {
die("Failed to bind one or more parameters.");
} //(if (!$bound1 || !$bound2 || !$bound3) )
// execute with bound parameters.
$result = db2_execute($stmt);
if (!$result) {
$code = db2_stmt_error();
$msg = db2_stmt_errormsg();
// TODO in production do not display SQL. Log it instead.
die("Failed to execute $sql. Reason: $code $msg");
} //(if (!$result))
if (!$counter) {
return array();//
} //(if (!$counter))
// success. create array to return to caller.
$rows = array();
while (($row = db2_fetch_assoc($stmt)) != false) {
$rows[] = $row;
} //(while...)
// this returns it to the caller.
return $rows;
} //(getParts)
谢谢!
【问题讨论】:
-
请给出出现错误的代码
-
好的,我把代码贴出来了。
标签: php ibm-midrange db2-400