Welcome Guest, Not a member yet? Register   Sign In
"outer" trans_start not rolling back "inner" trans_start records
#4

I know that you can do many queries within one trans_start() call, of course. The problem is that I have a function that can be called by other functions that MAY or MAY NOT call trans_start() first, and there is no way to check this in CodeIgniter.

I've wound up counting with a common model that has wrappers for the transaction functions in codeIgniter:


PHP Code:
function transBegin(){
     $this->_transBegin += 1;
     if($this->_transBegin ==1) {
         $this->db->trans_begin();
     }
}

function 
transCommit(){
     if($this->_transBegin == 1) {
          $this->db->trans_commit();
     }
     $this->_transBegin -= 1;
}

function 
transRollback(){
     if($this->_transBegin == 1) {
          $this->db->trans_rollback();
     }
     $this->_transBegin -= 1;

Reply


Messages In This Thread
RE: "outer" trans_start not rolling back "inner" trans_start records - by zimboden - 04-01-2017, 11:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB