cvs: pear /MDB2 MDB2.php

From: Date: Wed, 21 Jun 2006 10:19:29 +0000
Subject: cvs: pear /MDB2 MDB2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-40850@lists.php.net to get a copy of this message
lsmith Wed Jun 21 10:19:29 2006 UTC Modified files: /pear/MDB2 MDB2.php Log: - added ability to ignore the transaction counter when calling inTransaction() - minor tweaks to completeNestedTransaction() http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2.php?r1=1.224&r2=1.225&diff_format=u Index: pear/MDB2/MDB2.php diff -u pear/MDB2/MDB2.php:1.224 pear/MDB2/MDB2.php:1.225 --- pear/MDB2/MDB2.php:1.224 Wed Jun 21 10:13:10 2006 +++ pear/MDB2/MDB2.php Wed Jun 21 10:19:29 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.224 2006/06/21 10:13:10 lsmith Exp $ +// $Id: MDB2.php,v 1.225 2006/06/21 10:19:29 lsmith Exp $ // /** @@ -1893,6 +1893,7 @@ /** * If a transaction is currently open. * + * @param bool if the nested transaction count should be ignored * @return int|bool - an integer with the nesting depth is returned if a * nested transaction is open * - true is returned for a normal open transaction @@ -1900,9 +1901,9 @@ * * @access public */ - function inTransaction() + function inTransaction($ignore_nested = false) { - if (isset($this->nested_transaction_counter)) { + if (!$ignore_nested && isset($this->nested_transaction_counter)) { return $this->nested_transaction_counter; } return $this->in_transaction; @@ -1943,7 +1944,7 @@ function beginNestedTransaction() { if ($this->in_transaction) { - $this->nested_transaction_counter+= 1; + ++$this->nested_transaction_counter; return MDB2_OK; } $this->has_transaction_error = false; @@ -1968,21 +1969,23 @@ function completeNestedTransaction($force_rollback = false) { if ($this->nested_transaction_counter > 1) { - $this->nested_transaction_counter-= 1; + --$this->nested_transaction_counter; return MDB2_OK; } $this->nested_transaction_counter = null; - // transaction has already been rolled back - if (!$this->in_transaction) { - return MDB2_OK; - } + $result = MDB2_OK; - if ($force_rollback || $this->has_transaction_error) { - $this->has_transaction_error = false; - return $this->rollback(); + // transaction has not yet been rolled back + if ($this->in_transaction) { + if ($force_rollback || $this->has_transaction_error) { + $result = $this->rollback(); + } else { + $result = $this->commit(); + } } - return $this->commit(); + $this->has_transaction_error = false; + return $result; } // }}}

« previous php.pear.cvs (#40850) next »