What is the simplest way to judge the result set to be empty in mysqli
I found that judging the result set is not empty generally want to write this:
if ($result->num_rows>0) {}
And you can't write this:
if ($result)
I use Var_dump ($result); output, the result is
Object (Mysqli_result) #2 (0) {}
Visible, when the result set is empty, $result is an empty object with no members, I read the book said that when the object is converted to a Boolean, no member of the objects will be converted to false, otherwise converted to true, why here this empty object does not convert to false.
I also want to ask MySQL and PDO to determine the result set is empty also have to determine the number of records property is 0.
Share to:
------Solution--------------------
Yes, the result set is empty in MySQL and PDO, and you have to judge the number of records to be 0.