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 revision Previous revision
Next revision
Previous revision
v5:reference:connection:committrans [2018/06/11 10:23]
dregad [Usage] function names starting with lowercase (#426)
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 =====
Line 14: Line 20:
 $ok = $conn->execute($sql); $ok = $conn->execute($sql);
  
-if ($ok) +if ($ok) {
     $ok = $conn->execute($sql2);     $ok = $conn->execute($sql2);
 +}
  
-if (!$ok) +if (!$ok) {
     $conn->rollbackTrans();     $conn->rollbackTrans();
-else +else {
     $conn->commitTrans();     $conn->commitTrans();
-    +}
 </code> </code>
  
v5/reference/connection/committrans.1528705437.txt.gz · Last modified: 2018/06/11 10:23 by dregad