This is driving me crazy for days.
When I build query and insert in some of the tables it is commiting automatically, while other times it doesnt.
Checked all threads but nothing works. I have this code:
$this->db->trans_begin();
$q1 = $this->db->insert('log_query_actions', array('created_time' => '11:11:11'));
$q2 = $this->db->insert("db_sales", array('store_id' => '1'));
$q3 = $this->db->insert("db_sales", array('store_id' => '2'));
$q4 = $this->db->insert('log_query_actions', array('created_time' => '22:22:22'));
$q5 = $this->db->insert("db_sales", array('store_id' => '3'));
$q6 = $this->db->insert('log_query_actions', array('created_time' => '33:33:33'));
$this->db->trans_rollback();
After execution, in Database I can see the first 2 inserts for each table. The 3-rd insert in each table is successfully rolled back:
NOT ROOLLEDBACK $q1
NOT ROOLLEDBACK $q2
NOT ROOLLEDBACK $q3
NOT ROOLLEDBACK $q4
ROOLLEDBACK $q5
ROOLLEDBACK $q6
If I try something else, like:
$this->db->trans_begin();
$q1 = $this->db->insert('log_query_actions', array('created_time' => '11:11:11'));
$q4 = $this->db->insert('log_query_actions', array('created_time' => '22:22:22'));
$q6 = $this->db->insert('log_query_actions', array('created_time' => '33:33:33'));
$q2 = $this->db->insert("db_sales", array('store_id' => '1'));
$q3 = $this->db->insert("db_sales", array('store_id' => '2'));
$q5 = $this->db->insert("db_sales", array('store_id' => '3'));
$this->db->trans_rollback();
Then ONLY $q5 IS ROLLEDBACK. Everything else is in the table.
AND HERE COMES THE INTERESTING PART:
$this->db->trans_begin();
$q2 = $this->db->insert("db_sales", array('store_id' => '1'));
$q3 = $this->db->insert("db_sales", array('store_id' => '2'));
$q5 = $this->db->insert("db_sales", array('store_id' => '3'));
$q1 = $this->db->insert('log_query_actions', array('created_time' => '11:11:11'));
$q4 = $this->db->insert('log_query_actions', array('created_time' => '22:22:22'));
$q6 = $this->db->insert('log_query_actions', array('created_time' => '33:33:33'));
$this->db->trans_rollback();
In this case EVERYTHING IS ROLLEDBACK except $q2 and $q3.
What is happening with db_sales table that is commiting the changes? There are no internal relations, and Engine is INNODB not MyISAM