18-02-2010, 09:12 PM
Par exemple :
Code PHP :
<?php
mysqli_autocommit($connect,FALSE);
$requete = mysqli_query($connect, "SELECT Id,Traite,Operation FROM event WHERE Cfini<='$tempsactuel' AND Traite=0 ORDER BY Cfini ASC");
while( $result = mysqli_fetch_array($requete) )
{
if( $result['Operation'] == "PRODUNITE" )
{
if($result['Traite']==0)
{
$begin = mysqli_query($connect, "START TRANSACTION");
$majtraite = mysqli_query($connect, "UPDATE event SET Traite=1 WHERE Id='$idoperation' LIMIT 1");
// .... On effectue diverses opérations
// ....
// ... ayé c'est fini
if( $requetecom = mysqli_query($connect, "DELETE FROM event WHERE Id='$idoperation' LIMIT 1") )
{
$commit = mysqli_query($connect, "COMMIT");
}
else
{
$rollback = mysqli_query($connect, "ROLLBACK");
}
}
}
}