I am using old-style mysql_query()
functions to perform a transaction. It is not rolling back even though one of the queries in the transaction has failed. I have debugged affected rows and they are either 0 or 1. Syntax followed:
$cnx = mysql_connect( .. );
mysql_select_db("DB", $cnx);
mysql_query("START TRANSACTION");
mysql_query("BEGIN");
$isrollback = -1;
for (...) // run through query list
{
mysql_query(".... query_i ....");
if(mysql_affected_rows() == 0)
{
$isrollback = 1
}
}
// more queries
if ($isrollback > 0)
mysql_query("ROLLBACK");
else
mysql_query("COMMIT);