need to test if sql query was successful

后端 未结 11 1253
遥遥无期
遥遥无期 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:23

    global $DB;
    $status = $DB->query("UPDATE exp_members SET group_id = '$group_id' WHERE member_id = '$member_id'");
    
    if($status == false)
    { 
        die("Didn't Update"); 
    }
    

    If you are using mysql_query in the backend (whatever $DB->query() uses to query the database), it will return a TRUE or FALSE for INSERT, UPDATE, and DELETE (and a few others), commands, based on their status.

提交回复
热议问题