What's the point of disabling transactions? http://ellislab.com/codeigniter/user-guide/database/transactions.html
$this->db->trans_off()
I can't see the usage. Is it for testing purposes?
"When transactions are disabled, your queries will be auto-commited, just as they are when running queries without transactions."
I have a table called user
where there exists a column nameOfUser
. nameOfUser2
- column does NOT exist.
TEST1 This code would try to do 2 insertions with a normal transaction:
$this->db->trans_start();
$this->db->insert('user', array('nameOfUser' => 'testCVVCOOL'));
$this->db->insert('user', array('nameOfUser2' => 'test2'));
$this->db->trans_complete();
but it was rolled back (nothing is inserted) because the column nameOfUser2
-column does not exists in the second insert.
TEST2 This code would try to do 2 insertions with transaction disabled
$this->db->trans_off();
$this->db->trans_start();
$this->db->insert('user', array('nameOfUser' => 'testCVVCOOL'));
$this->db->insert('user', array('nameOfUser2' => 'test2'));
$this->db->trans_complete();
Above would insert testCVVCOOL string into user
-table even if there are an error in the second insert ($this->db->insert('user', array('nameOfUser2' => 'test2'));
)
When do you have the need for disabling transactions in this way?