# Coverage for Doctrine_Transaction_Mssql

Back to coverage report

1 | <?php
2 | /*
3 | * $Id: Mssql.php 2702 2007-10-03 21:43:22Z 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 Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
26 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
27 | * @package Doctrine
28 | * @subpackage Transaction
29 | * @link www.phpdoctrine.org
30 | * @since 1.0
31 | * @version $Revision: 2702 $
32 | */
33 | class Doctrine_Transaction_Mssql extends Doctrine_Transaction
34 | {
35 | /**
36 | * Set the transacton isolation level.
37 | *
38 | * @param string standard isolation level (SQL-92)
39 | * portable modes:
40 | * READ UNCOMMITTED (allows dirty reads)
41 | * READ COMMITTED (prevents dirty reads)
42 | * REPEATABLE READ (prevents nonrepeatable reads)
43 | * SERIALIZABLE (prevents phantom reads)
44 | * mssql specific modes:
45 | * SNAPSHOT
46 | *
47 | * @link http://msdn2.microsoft.com/en-us/library/ms173763.aspx
48 | * @throws PDOException if something fails at the PDO level
49 | * @throws Doctrine_Transaction_Exception if using unknown isolation level or unknown wait option
50 | * @return void
51 | */
52 | public function setIsolation($isolation, $options = array()) {
53 | switch ($isolation) {
54 | case 'READ UNCOMMITTED':
55 | case 'READ COMMITTED':
56 | case 'REPEATABLE READ':
57 | case 'SERIALIZABLE':
58 | case 'SNAPSHOT':
59 | break;
60 | default:
61 | throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation);
62 | }
63 |
64 | $query = 'SET TRANSACTION ISOLATION LEVEL ' . $isolation;
65 |
66 | $this->conn->execute($query);
67 | }
68 | }