Starts transaction.
|
bool i5_transaction ( |
int mode |
|
connection |
Connection ID |
|
mode |
Easycom constant (see above) |
Returns:
TRUE if transaction has started, FALSE in case of error.
|
I5_ERR_DESC_WRONG_DATAOP |
41 |
Wrong operation on a data field of a description |
|
I5_ERR_PARSEXML |
42 |
Internal error; please contact Aura Equipement; 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. |
Transactions management requires some rules, i.e. files journalization.
Several transaction modes are possible, they define isolation level, that means, if applied, if changes will be visible or not to other users as well as writing access (open in writing or restricted access).
Modes
|
I5_ISOLEVEL_CHG |
UR |
READ UNCOMMITED, READ WRITE |
|
|
Modified records remain locked. Modifications are showed. | |
|
I5_ISOLEVEL_CS |
CS |
READ COMMITED |
|
|
Read records are locked. Modified records remain locked. Changes are not showed. | |
|
I5_ISOLEVEL_ALL |
RS |
REPEATABLE READ |
|
|
Read records remain locked. Modified records remain locked. Modifications are not showed. | |
Options details are out of this documentation purpose, refer to iSeries and DB2 documentation (particularly LCKLVL parameter of STRCMTCTL command).
If a transaction is currently active, an I5_ALLREADYINTRAN error type will be generated.
<?php
$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_NONE, $conn);
/* Operations on ANIMALS table */
i5_query("INSERT INTO animals VALUE 'Cat', 'Mistigri'");
$res = i5_query("SELECT count(*) FROM animals");
$rec = i5_fetch_array($res);
echo $res[0] . "\n";
/* Transaction and DELETE request validation */
i5_commit($conn);
$res = i5_query("SELECT count(*) FROM animals");
$rec = i5_fetch_array($res);
echo $rec[0] . "\n";
i5_close($conn);
}
?>
?>