v5:reference:connection:committrans
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| reference:committrans [2015/08/08 19:42] – created 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.1439055737.txt.gz · Last modified: (external edit)
