如果我运行此代码,则即使myDB
table中的数据库中不存在数据记录,if子句也不会返回false myTable
。我不知道怎么了
// MySQLi-Connection...
$result = $mysqli->query("SELECT * FROM `myDB`.`myTable` WHERE `itemtype` = 'comment' AND `itemID` = 3");
if ($result) {
echo "record found!";
} else {
echo "record not found!";
}
itemID
= 3的记录不存在,但是我的if子句说$ result返回true。
Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries
mysqli_query() will return a mysqli_result object. For other successful queries
mysqli_query() will return TRUE.
您可以使用
$result = $mysqli->query("YOUR QUERY"));
if($result->num_rows){
// Records Found
}else{
// Empty Result
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句