need to test if sql query was successful

后端 未结 11 1248
遥遥无期
遥遥无期 2021-02-18 17:54

I have this query and if it returns successful, I want another function to process, if not, do not process that function.

Here is the code for running the query

11条回答
  •  孤城傲影
    2021-02-18 18:14

    This has proven the safest mechanism for me to test for failure on insert or update:

    $result = $db->query(' ... ');
    if ((gettype($result) == "object" && $result->num_rows == 0) || !$result) {
       failure 
    }
    

提交回复
热议问题