# Coverage for Doctrine_Transaction_Pgsql

Back to coverage report

1 | <?php
2 | /*
3 | * $Id: Pgsql.php 2963 2007-10-21 06:23:59Z Jonathan.Wage $
4 | *
5 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 | *
17 | * This software consists of voluntary contributions made by many individuals
18 | * and is licensed under the LGPL. For more information, see
19 | * <http://www.phpdoctrine.org>.
20 | */
21 | Doctrine::autoload('Doctrine_Transaction');
22 | /**
23 | *
24 | * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
25 | * @author Paul Cooper <pgc@ucecom.com> (PEAR MDB2 Pgsql driver)
26 | * @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
27 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
28 | * @package Doctrine
29 | * @subpackage Transaction
30 | * @link www.phpdoctrine.org
31 | * @since 1.0
32 | * @version $Revision: 2963 $
33 | */
34 | class Doctrine_Transaction_Pgsql extends Doctrine_Transaction
35 | {
36 | /**
37 | * createSavepoint
38 | * creates a new savepoint
39 | *
40 | * @param string $savepoint name of a savepoint to set
41 | * @return void
42 | */
43 | protected function createSavePoint($savepoint)
44 | {
45 | $query = 'SAVEPOINT ' . $savepoint;
46 |
47 | return $this->conn->execute($query);
48 | }
49 |
50 | /**
51 | * releaseSavePoint
52 | * releases given savepoint
53 | *
54 | * @param string $savepoint name of a savepoint to release
55 | * @return void
56 | */
57 | protected function releaseSavePoint($savepoint)
58 | {
59 | $query = 'RELEASE SAVEPOINT ' . $savepoint;
60 |
61 | return $this->conn->execute($query);
62 | }
63 |
64 | /**
65 | * rollbackSavePoint
66 | * releases given savepoint
67 | *
68 | * @param string $savepoint name of a savepoint to rollback to
69 | * @return void
70 | */
71 | protected function rollbackSavePoint($savepoint)
72 | {
73 | $query = 'ROLLBACK TO SAVEPOINT ' . $savepoint;
74 |
75 | return $this->conn->execute($query);
76 | }
77 |
78 | /**
79 | * Set the transacton isolation level.
80 | *
81 | * @param string standard isolation level
82 | * READ UNCOMMITTED (allows dirty reads)
83 | * READ COMMITTED (prevents dirty reads)
84 | * REPEATABLE READ (prevents nonrepeatable reads)
85 | * SERIALIZABLE (prevents phantom reads)
86 | * @throws PDOException if something fails at the PDO level
87 | * @throws Doctrine_Transaction_Exception if using unknown isolation level or unknown wait option
88 | * @return void
89 | */
90 | public function setIsolation($isolation)
91 | {
92 | switch ($isolation) {
93 | case 'READ UNCOMMITTED':
94 | case 'READ COMMITTED':
95 | case 'REPEATABLE READ':
96 | case 'SERIALIZABLE':
97 | break;
98 | default:
99 | throw new Doctrine_Transaction_Exception('Isolation level '.$isolation.' is not supported.');
100 | }
101 |
102 | $query = 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ' . $isolation;
103 | return $this->conn->execute($query);
104 | }
105 | }