PreviousNext
Help > API Functions > Transaction > i5_rollback
i5_rollback

 

Cancels current transaction.

 

 

 bool i5_rollback ([, resource connection])

 

 

Parameters

 

connection

Connection ID(optional)

 

Return

True if OK, false if failed.

 

I5_ERR_DESC_WRONG_DATAOP

41

Wrong operation on a data field of a description

I5_ERR_PARSEXML

42

Internal error; please contact Aura Equipements.

error number 42

I5_ERR_PHP_OPTIONSTYPE

259

The type of " I5_OPTIONS_ALIAS" option must be x

and not x

I5_ERR_PHP_OPTIONSNUMBER

260

Option number -1 is unknown.

I5_ERR_PHP_TYPEPARAM

262

Type of element x in parameter -1 must be y.

Type z was provided.

 

 Details

 

Cancels all changes made since transaction was started with i5_transaction function.

An I5_NOTINTRAN error will be generated if no transaction was started.

 

Example

 

$conn = i5_connect"MON_AS", "USER", "PASSWORD");

if ($conn)

{
    $res = i5_query("SELECT count(*) FROM animals");
    $rec = i5_fetch_array($res );
    echo $rec[0] . "\n";
    

    /* Transaction beginning */

    i5_transaction(I5_ISOLEVEL_CHG, $conn); 

   

    /* All ANIMALS lines deletion */
    i5_query("DELETE * FROM animals");
    
    $res = i5_query("SELECT count(*) FROM animals");
    $rec = i5_fetch_array($res);
    echo $rec[0] . "\n";


    /* Cancel DELETE request */
    $ret = i5_rollback($conn);

    if (!$ret)

    {

                   print_r("i5_rollback error : ".i5_errormsg().'<br/>');

    }

    else

    {
    
                $res = i5_query("SELECT count(*) FROM animals");
                   $rec = i5_fetch_array($res);
                   echo $rec[0] . "\n";

    }

}

 

 

See also

 

i5_transaction

i5_commit