[英]How can I determine if an SQL result has been returned in PHP?
I am trying to condition a table so that it only shows when SQL results are returned. 我试图对表进行条件处理,以便仅在返回SQL结果时显示。 If no values are returned, then do not display the table.
如果未返回任何值,则不显示该表。 Here is what I have:
这是我所拥有的:
## PPAP Information
$q23 = "SELECT * FROM $modlible.P0353 JOIN $amflible.CUSMAS ON PCUSNO = CUSNO WHERE PITEM='$id'";
$stmt23 = db2_prepare($con, $q23);
$result23 = db2_execute($stmt23);
$fin23 = db2_fetch_assoc($stmt23);
How can I detect whether or not a result has been returned to me? 如何检测结果是否已退还给我?
You can check the SQL code returned. 您可以检查返回的SQL代码。 If the code is SQL0100 (+100) it means no rows were returned.
如果代码是SQL0100(+100),则表示未返回任何行。
If there are no results your while loop will not loop 如果没有结果,则while循环不会循环
while($fin23 = db2_fetch_assoc($stmt23)){
// print your results
}
This might help 这可能有帮助
$iRows = db2_num_rows($stmt23);
if ($iRows > 0) {
//Do if zero results
} else {
//Do if more results
}
or you can check 或者你可以检查
if ($fin23) {
//Row was fetched
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.