Welcome Guest, Not a member yet? Register   Sign In
Force database transaction to rollback.
#1

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

How do I force a transaction to rollback, using the automatic method.
( The manual method supports nested transactions in MySQL? As far as I know it does not support. )

Code:
try
{
    // Begin first transaction
    $this->db->trans_start();
    $this->db->query('<anything>');

        // Begin nested transaction
        $this->db->trans_start();
        $this->db->query('<anything>');

        // Some 'assertion' code
        if( true )
            throw new Exception('Force everything to rollback');

        $this->db->trans_complete();

    // Finishing outermost trans
    $this->db->trans_complete();
}
catch(Exception $ex)
{
    // How do I rollback both transactions?
    // $this->db->rollback(); ??
}

Thanks for your attention.


Messages In This Thread
Force database transaction to rollback. - by El Forum - 06-27-2012, 07:58 AM
Force database transaction to rollback. - by El Forum - 06-27-2012, 02:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB