ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:committrans

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:reference:connection:committrans [2016/01/17 00:21] – ↷ Page moved from v5:reference:committrans to v5:reference:connection:committrans mnewnhamv5: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 ==
-  void commitTrans()+  bool commitTrans( 
 +    optional bool $ok = true 
 +    )
 </WRAP> </WRAP>
 ===== Descriptions ===== ===== Descriptions =====
 The function ''commitTrans()'' commits a granular transaction. This function is not part of the smart transaction set, you must verify that all transactional statements within the transaction scope have completed correctly. The function ''commitTrans()'' commits a granular transaction. This function is not part of the smart transaction set, you must verify that all transactional statements within the transaction scope have completed correctly.
 +
 +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->Execute($sql);+
  
-if ($ok)  +$ok = $conn->execute($sql);
-    $ok = $conn->Execute($sql2);+
  
-if (!$ok)  +if ($ok) { 
-    $conn->RollbackTrans();+    $ok = $conn->execute($sql2); 
 +}
  
-else  +if (!$ok) { 
-    $conn->CommitTrans(); +    $conn->rollbackTrans(); 
-    +} else { 
 +    $conn->commitTrans(); 
 +}
 </code> </code>
  
v5/reference/connection/committrans.txt · Last modified: 2021/04/26 14:02 by peterdd