Ragazzi ho un problema con le transazioni ma non riesco a trovare l'inghippo...

Ho una classe PHP per la gestione del database ed oggi le ho aggiunto del codice per gestire la transazioni...però ha un comportamento anomalo, vi spiego come funziona:

1) Memorizzo in un array le varie "query" da eseguire nella transazione [ function transaction($query) ]
2) Successivamente invocando la [ function execute() ] eseguo tutte le query precedentemente memorizzate ed alla prima query che mi da errore stoppo il ciclo ed eseguo ROLLBACK

l'anomalia sta nel fatto che se la query a dare problemi è la prima ad essere eseguita tutto ok, mentre negli altri casi se ho ad esempio 10 query ed è la 4 a dare problemi è come se non si fermasse l'esecuziona anche se poi nel database è presente solo la 1° query...

ecco la parte di codice relativa:
Codice PHP:
class database {
    var 
$transaction_id 0;
    var 
$transaction_queue "";

    function 
transaction($query) {
        if (
$this->mysql_version >= 5) {
            
$query str_replace("''""NULL"$query);
        }

        if (!
$this->id_connessione) {
            
$this->print_db_error("
ERROR: Errore Connessione.
Non si è connessi al database, impossibile eseguire la query!
"
);
        }

        
$this->transaction_id++;
        
$this->transaction_queue[$this->transaction_id] = $query;
    }

    function 
execute() {
        if ( 
$this->query("START TRANSACTION") ) {
            
$this->transaction true;
            for ( 
$indice 1$indice <= count($this->transaction_id); $indice++ ) {
                
$result = @mysql_query($this->transaction_queue[$indice], $this->id_connessione);
                
// Abort in caso di errore
                
if ( !$result ) {
                    
$error_type mysql_error();
                    
$error_id mysql_errno();

                    echo(
"
ERROR: Errore Database.
Impossibile eseguire la query: 
{$this->transaction_queue[$indice]}.

[b]Errore MySQL ritornato[/b]: 
$error_type
[b]Codice Errore MySQL[/b]: 
$error_id

[b]Transaction Aborted - Rollback[/b]"
);
                    break;
                }
            }

            if ( 
$result ) {
                
$this->query("COMMIT");
                return 
true;
            } else {
                
$this->query("ROLLBACK");
                return 
false;
            }

            
$this->transaction_id 0;
            
$this->transaction_queue "";
        }
    }

non riesco a capire xkè non va...help please...