Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * dblib doesn't support transactions so we need to add a workaround for transactions, last insert ID, and quoting
5
 *
6
 * @package    propel.adapter.MSSQL
7
 */
8
class MssqlDebugPDO extends DebugPDO
9
{
10
	/**
11
	 * Begin a transaction.
12
	 *
13
	 * It is necessary to override the abstract PDO transaction functions here, as
14
	 * the PDO driver for MSSQL does not support transactions.
15
	 */
16
	public function beginTransaction()
17
	{
18
		$return = true;
19
		$opcount = $this->getNestedTransactionCount();
20
		if ( $opcount === 0 ) {
21
			$return = self::exec('BEGIN TRANSACTION');
22
			$this->isUncommitable = false;
23
		}
24
		$this->incrementNestedTransactionCount();
25
		return $return;
26
	}
27
 
28
	/**
29
	 * Commit a transaction.
30
	 *
31
	 * It is necessary to override the abstract PDO transaction functions here, as
32
	 * the PDO driver for MSSQL does not support transactions.
33
	 */
34
  public function commit()
35
	{
36
		$return = true;
37
		$opcount = $this->getNestedTransactionCount();
38
		if ($opcount > 0) {
39
			if ($opcount === 1) {
40
				if ($this->isUncommitable) {
41
					throw new PropelException('Cannot commit because a nested transaction was rolled back');
42
				} else {
43
					$return = self::exec('COMMIT TRANSACTION');
44
				}
45
			}
46
			$this->decrementNestedTransactionCount();
47
		}
48
		return $return;
49
	}
50
 
51
	/**
52
	 * Roll-back a transaction.
53
	 *
54
	 * It is necessary to override the abstract PDO transaction functions here, as
55
	 * the PDO driver for MSSQL does not support transactions.
56
	 */
57
	public function rollBack()
58
	{
59
		$return = true;
60
		$opcount = $this->getNestedTransactionCount();
61
		if ($opcount > 0) {
62
			if ($opcount === 1) {
63
				$return = self::exec('ROLLBACK TRANSACTION');
64
			} else {
65
				$this->isUncommitable = true;
66
			}
67
			$this->decrementNestedTransactionCount();
68
		}
69
		return $return;
70
	}
71
 
72
	/**
73
	 * Rollback the whole transaction, even if this is a nested rollback
74
	 * and reset the nested transaction count to 0.
75
	 *
76
	 * It is necessary to override the abstract PDO transaction functions here, as
77
	 * the PDO driver for MSSQL does not support transactions.
78
	 */
79
	public function forceRollBack()
80
	{
81
		$return = true;
82
		$opcount = $this->getNestedTransactionCount();
83
		if ($opcount > 0) {
84
			// If we're in a transaction, always roll it back
85
			// regardless of nesting level.
86
			$return = self::exec('ROLLBACK TRANSACTION');
87
 
88
			// reset nested transaction count to 0 so that we don't
89
			// try to commit (or rollback) the transaction outside this scope.
90
			$this->nestedTransactionCount = 0;
91
		}
92
		return $return;
93
	}
94
 
95
	public function lastInsertId($seqname = null)
96
	{
97
		$result = self::query('SELECT SCOPE_IDENTITY()');
98
		return (int)$result->fetchColumn();
99
	}
100
 
101
	public function quoteIdentifier($text)
102
	{
103
		return '[' . $text . ']';
104
	}
105
 
106
	public function useQuoteIdentifier()
107
	{
108
		return true;
109
	}
110
}