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

Next revision
Previous revision
v5:reference:connection:committrans [2015/08/08 19:42]
mnewnham created
v5:reference:connection:committrans [2021/04/26 14:02] (current)
peterdd as in sources: return bool instead of void, document optional parameter
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.1439055737.txt.gz · Last modified: 2017/04/21 11:36 (external edit)