Welcome Guest, Not a member yet? Register   Sign In
Transaction Rollback
#1

[eluser]Fábio[/eluser]
Hello,

I am looking for a way to force rollback transactions manually using the trans_start and trans_complete methods.

The trans_complete method only detects failures generated by database , but what should I do when I need that the php code to fire the transaction rollback.

Thanks in advance,

Fabio

PS: The other option, trans_begin / trans_commit / trans_rollback doesn't help me, because it doesn't support transaction nesting.
#2

[eluser]Sudz[/eluser]
Hi,

Make sure to use $this->db->trans_begin() when running manual transactions, NOT $this->db->trans_start()

Below is example
Code:
$this->db->trans_begin();

$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');

if ($this->db->trans_status() === FALSE)
{
    // Here you can rollback if any of above query fails
    $this->db->trans_rollback();

}
else
{
    $this->db->trans_commit();
}




Theme © iAndrew 2016 - Forum software by © MyBB