What's the point of disabling transactions (in ActiveRecord CodeIgniter)? What's the point of disabling transactions (in ActiveRecord CodeIgniter)? codeigniter codeigniter

What's the point of disabling transactions (in ActiveRecord CodeIgniter)?


When do you have the need for disabling transactions in this way?

My understanding is transactions don't allow more interaction in the same thread if there is an issue (as in your first example). So, if you wanted to do something else in the db before the commit and before the rollback, you wouldn't be able to.

Pseudo-example:

//will not work$this->db->trans_start();$this->db->insert('user', array('nameOfUser' => 'testCVVCOOL'));$this->db->insert('user', array('nameOfUser2' => 'test2'));//more likely this would be a condition that makes sense //perhaps using a query result from earlier in functionif(1===1){    $this->db->query('INSERT INTO errors (db) values (1)');//nogo}$this->db->trans_complete(); 

-

//will work$this->db->trans_off();$this->db->trans_start();$this->db->insert('user', array('nameOfUser' => 'testCVVCOOL'));$this->db->insert('user', array('nameOfUser2' => 'test2'));//more likely this would be a condition that makes sense //perhaps using a query result from earlier in functionif(1===1){    $this->db->query('INSERT INTO errors (db) values (1)');//OK}$this->db->trans_complete(); 


It totally depends upon our scenario where we are using the transactions -

When Transaction is needed:

Need a set of operations at whole i.e. If some one orders a product online, and there are some steps involved in order confirmation then if any step is get failed then revert the whole order transaction.

When Transaction Off is needed:

If I am trying some stuff where any type of info is worth for me. Then we can use transaction off feature. Whatever error is occurred, save the data, which meets the criteria.