且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php无法使用Empty()检查PDO结果是否为空,返回致命错误

更新时间:2023-11-28 19:43:46

您需要将结果分配给变量,然后对该变量调用 empty().这只是 empty()函数的一个令人讨厌的限制.参见问题.

You need to assign the results to a variable, then call empty() on the variable. It's just an annoying limitation of the empty() function. See this question.

$results = $pQuery1->fetch(PDO::FETCH_ASSOC);
if (empty($results)){}