transactions in PHP

0

I currently have a function that eliminates all the information about a problem in different tables with this code:

function eliminar_ejercicio_por_id($idproblema){
    $conn = db_connect();
    $query = "DELETE FROM activacion WHERE idproblema=$idproblema";

    $result = @$conn->query($query);

    $query = "DELETE FROM registro WHERE idproblema=$idproblema";

    $result = @$conn->query($query);

    $query = "DELETE FROM revisados WHERE idproblema=$idproblema";

    $result = @$conn->query($query);

    $query = "DELETE FROM problemas WHERE idproblema=$idproblema";

    return $result;
}

but as you can see these queries are not a transaction, what I want to do is that if a failure does not save any change in the database (I think you do roll back) and tell me the error ... if everything goes well that I return the confirmation (I think commit), the problem is that I do not know how to do that in PHP

    
asked by Yept 09.03.2018 в 03:10
source

0 answers