v5:userguide:transactions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v5:userguide:transactions [2016/02/27 17:19] – [Smart Transactions] mnewnham | v5:userguide:transactions [2020/08/26 10:09] (current) – [Usage] Add braces as suggested by @peterdd in #629 dregad | ||
---|---|---|---|
Line 27: | Line 27: | ||
[[v5: | [[v5: | ||
[[v5: | [[v5: | ||
- | [[v5: | + | [[v5: |
+ | == See Also == | ||
+ | [[v5: | ||
+ | [[v5: | ||
</ | </ | ||
When using granular transactions, | When using granular transactions, | ||
Line 43: | Line 46: | ||
$ok = $conn-> | $ok = $conn-> | ||
- | if ($ok) | + | if ($ok) { |
/* | /* | ||
* The previous execution succeeded, do some more | * The previous execution succeeded, do some more | ||
| | ||
$ok = $conn-> | $ok = $conn-> | ||
- | else | + | } else { |
/* | /* | ||
* Branch, do some other work, then return | * Branch, do some other work, then return | ||
*/ | */ | ||
- | if (!$ok) | + | } |
+ | |||
+ | if (!$ok) | ||
/* | /* | ||
* Test the last insertion, if not successful roll | * Test the last insertion, if not successful roll | ||
Line 58: | Line 63: | ||
*/ | */ | ||
$conn-> | $conn-> | ||
- | else | + | } else { |
/* | /* | ||
* Go ahead and commit | * Go ahead and commit | ||
*/ | */ | ||
$conn-> | $conn-> | ||
+ | } | ||
</ | </ | ||
----------------------------- | ----------------------------- | ||
Line 72: | Line 78: | ||
[[v5: | [[v5: | ||
[[v5: | [[v5: | ||
+ | == See Also == | ||
+ | [[v5: | ||
+ | [[v5: | ||
</ | </ | ||
- | Smart Transactions are much easier to use in large procedures because you do not have to track the error status. You start a smart transaction by calling | + | Smart Transactions are much easier to use in large procedures because you do not have to track the error status. You start a smart transaction by calling |
<code php> | <code php> | ||
Line 84: | Line 93: | ||
* Execute some SQL | * Execute some SQL | ||
*/ | */ | ||
- | $conn->Execute($sql); | + | $conn->execute($sql); |
/* | /* | ||
* Execute some more SQL | * Execute some more SQL | ||
*/ | */ | ||
- | $conn->Execute($sql2); | + | $conn->execute($sql2); |
/* | /* | ||
Line 107: | Line 116: | ||
$conn-> | $conn-> | ||
- | if (!CheckRecords()) | + | if (!checkRecords()) |
$conn-> | $conn-> | ||
Line 114: | Line 123: | ||
* it will also be rolled back | * it will also be rolled back | ||
*/ | */ | ||
- | $conn->Execute($sql2); | + | $conn->execute($sql2); |
- | $conn->CompleteTrans(); | + | $conn->completeTrans(); |
</ | </ | ||
Line 123: | Line 132: | ||
* There was an error in the SQL execution. This execution comprises all scenarios where the SQL statement was successfully issued, but failed to complete. This does not include scenarios where the construction of the statement failed, and an error occurred that was trapped by PHP error handling. | * There was an error in the SQL execution. This execution comprises all scenarios where the SQL statement was successfully issued, but failed to complete. This does not include scenarios where the construction of the statement failed, and an error occurred that was trapped by PHP error handling. | ||
- | Make sure you call '' | + | Make sure you call '' |
Line 142: | Line 151: | ||
*/ | */ | ||
$conn-> | $conn-> | ||
- | if (!CheckRecords()) | + | if (!checkRecords()) |
/* | /* | ||
* This is applied to the outer block | * This is applied to the outer block | ||
Line 161: | Line 170: | ||
==== Savepoints ==== | ==== Savepoints ==== | ||
Savepoints are currently not supported. | Savepoints are currently not supported. | ||
- |
v5/userguide/transactions.1456589941.txt.gz · Last modified: 2017/04/21 11:39 (external edit)