在作者表中查询作者名为 “我吃西红”(表中不存在)的记录
$author_name = "我吃西红";
$sql = "select `author_id` from `n_author` where `author_name` = '$author_name'";
$rs = execQuery($sql,$link);
if($rs==null)echo "return is null <br>";
if($rs=="")echo "return is empty <br>";
if($rs==false)echo "return is false <br>";
打印结果如下:

可以看出,当结果集为空时,返回值==null、false是成立的
最后使用var_dump()查看一下
var_dump($rs);

本文探讨了在MySQL查询中,当搜索条件未命中任何记录时,返回值的情况。通过示例查询不存在的作者名“我吃西红”,结果显示返回值为null或false。通过PHP的var_dump()函数进一步验证了这一结论。
676

被折叠的 条评论
为什么被折叠?



