Mysql查询当结果集为空时(无结果)的返回值
在作者表中查询作者名为 “我吃西红”(表中不存在)的记录
$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);
还没有评论,来说两句吧...