Welcome Guest, Not a member yet? Register   Sign In
Rollback all queries after unsaccessfull transaction
#1

[eluser]levani[/eluser]
I have the following queries inside a transaction:

Code:
$this->db->trans_begin();
$query = $this->db->where('id', $user_id)->set('`points`', "`points` + $point", FALSE)->update('users');
$this->db->insert('logs', $logData);
if ($this->db->trans_status() === FALSE)
{
    $this->db->trans_rollback();
}
else
{
    $this->db->trans_commit();
}

The problem is that the second query is still executed even if the first one has failed. For example when I change the table name from 'users' to something else, of course the first query fails but is insert is still made. Is this the correct behavior of transaction?
#2

[eluser]PhilTem[/eluser]
I don't have a solution, but an idea: What's the type of your second table? As far as I know only the InnoDB engine supports transactions. That may be why you can't roll it back if the table engine isn't InnoDB
#3

[eluser]levani[/eluser]
[quote author="PhilTem" date="1338746638"]I don't have a solution, but an idea: What's the type of your second table? As far as I know only the InnoDB engine supports transactions. That may be why you can't roll it back if the table engine isn't InnoDB[/quote]

Thanks for reminding that. I checked it out and the type of the second table was MyISAM.




Theme © iAndrew 2016 - Forum software by © MyBB