I think that will be better use try/catch in tour code:
$processes = array();
$processes[] = "INSERT_QUERY_STRING"; //query1
//this loop can be turn more than 100 times
while(CONDITION) {
//query generated here
$processes[] = "UPDATE_QUERY_STRING"; //looping queries
}
$processes[] = "UPDATE_QUERY_STRING"; //last query
mysql_query("SET AUTOCOMMIT=0");
mysql_query("START TRANSACTION");
$count_processes = count($processes);
for($i=0; $i < $count_processes; $i++)
{
try {
$q = mysql_query($processes[$i]);
if (!$q) throw new Exception(mysql_error());
}
catch (Exception $e) {
mysql_query("ROLLBACK");
break;
}
}
mysql_query("COMMIT");
mysql_query("SET AUTOCOMMIT=1");
Use try/catch is better because you have control over the code and error :)