v5:reference:connection:committrans
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v5:reference:connection:committrans [2016/01/17 00:21] – ↷ Page moved from v5:reference:committrans to v5:reference:connection:committrans mnewnham | v5:reference:connection:committrans [2021/04/26 14:02] (current) – as in sources: return bool instead of void, document optional parameter peterdd | ||
---|---|---|---|
Line 3: | Line 3: | ||
<WRAP right box> | <WRAP right box> | ||
== Syntax == | == Syntax == | ||
- | | + | |
+ | optional bool $ok = true | ||
+ | | ||
</ | </ | ||
===== Descriptions ===== | ===== Descriptions ===== | ||
The function '' | The function '' | ||
+ | |||
+ | Set parameter $ok to true to commit, false to rollback the transaction. | ||
+ | |||
+ | Return bool true if successful. | ||
--------------------------------- | --------------------------------- | ||
===== Usage ===== | ===== Usage ===== | ||
<code php> | <code php> | ||
- | $conn->BeginTrans(); | + | $conn->beginTrans(); |
- | + | ||
- | $ok = $conn-> | + | |
- | if ($ok) | + | $ok = $conn->execute($sql); |
- | | + | |
- | if (!$ok) | + | if ($ok) { |
- | $conn->RollbackTrans(); | + | |
+ | } | ||
- | else | + | if (!$ok) { |
- | $conn->CommitTrans(); | + | $conn->rollbackTrans(); |
- | | + | } else { |
+ | | ||
+ | } | ||
</ | </ | ||
v5/reference/connection/committrans.1452986502.txt.gz · Last modified: 2017/04/21 11:36 (external edit)