Con l'auto commite = 0 ho già provato... e cmq io apro due connessioni distinte e poi a ogni query che devo eseguire gli passo l'identificativo della connessione per capire se la query deve essere eseguita online o in locale..... e la cosa funziona... xke se eseguo semplicemente una cosa del tipo
> apro connessione internet
> apro connessione locale
> prendo dei dati da locale e li sparo online
> prendo dei dati da internet e li sparo in locale
> se tutto ok eseguo il commite di entrambi
funziona tranquillamente... è questo ke non mi spiego... appena aumenta la mole dei dati non va piu'...
se ti puo' essere di aiuto questo è quello che funziona (cioè che i dati non vengono confermati finche non do il commite... quelli che non funzionano sono identici salvo ke le query sono un pokino di piu')
Codice PHP:
try
{
$LOCALE_start = mysql_query("START TRANSACTION", $cn_locale);
if (!$LOCALE_start) throw new Exception("Errore apertura transazione locale: ".mysql_error($cn_locale));
$INTERNET_start = mysql_query("START TRANSACTION", $cn_internet);
if (!$INTERNET_start) throw new Exception("Errore apertura transazione internet: ".mysql_error($cn_internet));
$LOCALE_sql_1 = "SELECT * FROM ...";
$LOCALE_query_1 = mysql_query($LOCALE_sql_1, $cn_locale);
if (!$LOCALE_query_1) throw new Exception("Errore LOCALE_query_1 ".mysql_error($cn_locale));
$LOCALE_num_1 = mysql_num_rows($LOCALE_query_1);
if ($LOCALE_num_1 > 0)
{
$i = 0;
while ($LOCALE_dati_1 = mysql_fetch_array($LOCALE_query_1, MYSQL_ASSOC))
{
$INTERNET_sql_1 = "SELECT ...";
$INTERNET_query_1 = mysql_query($INTERNET_sql_1, $cn_internet);
if (!$INTERNET_query_1) throw new Exception("Errore INTERNET_query_1 ".mysql_error($cn_internet));
$INTERNET_num_1 = mysql_num_rows($INTERNET_query_1);
if ($INTERNET_num_1 > 0)
{
$INTERNET_sql_2 = "UPDATE ...";
}//end if $INTERNET_num_1 > 0
else
{
$INTERNET_sql_2 = "INSERT INTO ...";
}//end else $INTERNET_num_1 > 0
$INTERNET_query_2 = mysql_query($INTERNET_sql_2, $cn_internet);
if (!$INTERNET_query_2) throw new Exception("Errore INTERNET_query_2 ".mysql_error($cn_internet));
else $i++;
}//end while
if ($i != $LOCALE_num_1 ) throw new Exception("Errore contatore while su LOCALE_query_1");
}//end $LOCALE_num_1 > 0
//LIBERO LA MEMORIA
mysql_free_result($LOCALE_query_1);
$LOCALE_sql_2 = "TRUNCATE TABLE ...";
$LOCALE_query_2 = mysql_query($LOCALE_sql_2, $cn_locale);
if (!$LOCALE_query_2) throw new Exception("Errore LOCALE_query_2 ".mysql_error($cn_locale));
$INTERNET_sql_3 = "SELECT * ...";
$INTERNET_query_3 = mysql_query($INTERNET_sql_3, $cn_internet);
if (!$INTERNET_query_3) throw new Exception("Errore INTERNET_query_3 ".mysql_error($cn_internet));
$INTERNET_num_3 = mysql_num_rows($INTERNET_query_3);
if ($INTERNET_num_3 > 0)
{
$i = 0;
while ($INTERNET_dati_3 = mysql_fetch_array($INTERNET_query_3, MYSQL_ASSOC))
{
$LOCALE_sql_3 = "INSERT INTO ...";
$LOCALE_query_3 = mysql_query($LOCALE_sql_3, $cn_locale);
if (!$LOCALE_query_3) throw new Exception("Errore LOCALE_query_3 ".mysql_error($cn_locale));
else $i++;
}//end while
if ($i != $INTERNET_num_3) throw new Exception("Errore contatore while su INTERNET_query_3");
}//end $INTERNET_num_3 > 0
//LIBERO LA MEMORIA
mysql_free_result($INTERNET_query_3);
//CONFERMO LE OPERAZIONI
$LOCALE_end = mysql_query("COMMIT", $cn_locale);
if (!$LOCALE_end) throw new Exception("Errore chiusura transazione locale: ".mysql_error($cn_locale));
$INTERNET_end = mysql_query("COMMIT", $cn_internet);
if (!$INTERNET_end) throw new Exception("Errore chiusura transazione internet: ".mysql_error($cn_internet));
$RESULT = true;
}//end try
catch (Exception $e)
{
$RESULT = false;
$LOCALE_end = mysql_query("ROLLBACK", $cn_locale);
$INTERNET_end = mysql_query("ROLLBACK", $cn_internet);
echo $e;
}