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

Thanks. I do know that it works with multiple queries using only one trans_start(), but my problem is I have a function that creates a lot of records and it can be called by a function that function that MAY or MAY NOT have called trans_start() already. My solution was to count the trans_start() calls by using a wrapper in a common model function like this:

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, 09:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB