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