4 * Represents current transaction state of a connection.
6 final class AphrontDatabaseTransactionState
extends Phobject
{
9 private $readLockLevel = 0;
10 private $writeLockLevel = 0;
12 public function getDepth() {
16 public function increaseDepth() {
17 return ++
$this->depth
;
20 public function decreaseDepth() {
21 if ($this->depth
== 0) {
24 'Too many calls to %s or %s!',
26 'killTransaction()'));
29 return --$this->depth
;
32 public function getSavepointName() {
33 return 'Aphront_Savepoint_'.$this->depth
;
36 public function beginReadLocking() {
37 $this->readLockLevel++
;
41 public function endReadLocking() {
42 if ($this->readLockLevel
== 0) {
45 'Too many calls to %s!',
48 $this->readLockLevel
--;
52 public function isReadLocking() {
53 return ($this->readLockLevel
> 0);
56 public function beginWriteLocking() {
57 $this->writeLockLevel++
;
61 public function endWriteLocking() {
62 if ($this->writeLockLevel
== 0) {
65 'Too many calls to %s!',
68 $this->writeLockLevel
--;
72 public function isWriteLocking() {
73 return ($this->writeLockLevel
> 0);
76 public function __destruct() {
80 'Process exited with an open transaction! The transaction '.
81 'will be implicitly rolled back. Calls to %s must always be '.
82 'paired with a call to %s or %s.',
85 'killTransaction()'));
87 if ($this->readLockLevel
) {
90 'Process exited with an open read lock! Call to %s '.
91 'must always be paired with a call to %s.',
95 if ($this->writeLockLevel
) {
98 'Process exited with an open write lock! Call to %s '.
99 'must always be paired with a call to %s.',
100 'beginWriteLocking()',
101 'endWriteLocking()'));