Welcome Guest, Not a member yet? Register   Sign In
mysqli and nested transactions
#1

Hi! It seems that nested transactions work correctly using $this->db->trans_start (and the appropriate fix from here https://ellislab.com/forums/viewthread/101648/) but the behaviour it's different when using $this->db->trans_begin

PHP Code:
public function trx_test() {
 
       $this->db->trans_begin();
 
       
        $this
->db->insert('test_tbl', array('id' => 0));
 
       
        $this
->db->trans_begin();
 
       
        $this
->db->insert('test_tbl', array('id' => 1));

 
       $this->db->trans_rollback();
 
       
        $this
->db->trans_commit();


test_table contains only 1 row with id = 0


PHP Code:
public function trx_test_2() {
        
$this->db->trans_start();
        
        
$this->db->insert('test_tbl', array('id' => 0));
        
        
$this->db->trans_start();
        
        
$this->db->insert('test_tbl', array('id' => 1));

        
$this->db->trans_rollback();
        
        
$this->db->trans_complete();


test_table contains no rows


Is this difference by design or what? I'm expecting same behaviour (the correct one should be the one from trx_test_2).
Reply


Messages In This Thread
mysqli and nested transactions - by geekita - 11-21-2014, 06:11 AM
RE: mysqli and nested transactions - by geekita - 11-28-2014, 05:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB