PreviousNext
Help > API Functions > Transaction > i5_commit
i5_commit

 

 Validates current transaction.

 

 

 bool i5_commit (string comment [, resource connection])

 

 

Parameters

 

comment

Chain with transaction comment

connection

Connection ID

 

 

Return

TRUE if transaction is valid, FALSE in case of error.  

 

I5_ERR_PHP_HDLDFT

256

No default connection found.

I5_ERR_PHP_HDLCONN

257

This resource has no connection active.

I5_ERR_PHP_RESOURCE_BAD

261

No resource found.

I5_ERR_PHP_TYPEPARAM

262

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

Type z was provided.

I5_ERR_PHP_TYPEPARAM

262

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

Type z was provided.

I5_ERR_PHP_NBPARAM_BAD

263

Wrong parameter count

 

 

Details

 Validate current transaction started with i5_transaction function for the specified connection.

A comment will be added in the journal file.

All files involved in a transaction must be journalized.

See column Journals and transactions with I5 files.

 

 

Example

 


$conn = i5_connect("MY_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); 

   
    /* Lines insertion in ANIMALS */
    i5_query("INSERT INTO Animals VALUES ('CAT', 'Misstic', 'F', 3.2)");
    i5_query("INSERT INTO Language VALUES ('DOG', 'Hercule', 'M', 4.4)");
    
    $res = i5_query("SELECT count(*) FROM animals");
    $rec = i5_fetch_array($res);
    echo $rec[0] . "\n";
    
    /* Transaction validation */
   $ret = i5_commit($conn);

    if (!$ret)

    {

                   print_r("i5_commit 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_rollback