When I Create A Transactions By Cdbtransaction ,it Doesn't Work

My code is:

    $transaction=$this->db->beginTransaction();


    try{


   


            $r1 = $this->insert($data1);


            $r2 = $this->insert($data2);


            $transaction->commit();


    }catch(Exception $e){


       $transaction->rollback();


    }


    if($r1 && $r2){


            return true;


    }else{


            return false;


    }

my problem is ,if I have a exception in a sql,but It doesn’t rollback ,so the first sql is execute success ,other one is fail;

and another problem ,I found if I comment line $transaction->commit();the sql still can execute ,why ?

code explain:

$this->db is a instance of CDbConnection

what dbms are you using? if mysql - what storage type? if MyISAM - they do not support transactions…

thanks for your reminding ,I used mysql MyISAM . :rolleyes: thank you !