Best way to check if MySQL results returned in PHP?

前端 未结 11 1053
长情又很酷
长情又很酷 2020-11-28 23:21

I\'m looking for the best way to check and see if any results were returned in a query. I feel like I write this part of code a lot and sometimes I get errors, and sometimes

11条回答
  •  执笔经年
    2020-11-28 23:58

    $result = $mysqli->query($query);
    if($result){
        perform action
    }
    

    this is how i do it, you could also throw an else there with a die...

提交回复
热议问题