Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/*
3
 *  $Id: Mssql.php 7490 2010-03-29 19:53:27Z jwage $
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.doctrine-project.org>.
20
 */
21
 
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.doctrine-project.org
30
 * @since       1.0
31
 * @version     $Revision: 7490 $
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
 
69
    /**
70
     * Performs the rollback.
71
     */
72
    protected function _doRollback()
73
    {
74
        $this->conn->getDbh()->exec('ROLLBACK TRANSACTION');
75
    }
76
 
77
    /**
78
     * Performs the commit.
79
     */
80
    protected function _doCommit()
81
    {
82
        $this->conn->getDbh()->exec('COMMIT TRANSACTION');
83
    }
84
 
85
    /**
86
     * Begins a database transaction.
87
     */
88
    protected function _doBeginTransaction()
89
    {
90
        $this->conn->getDbh()->exec('BEGIN TRANSACTION');
91
    }
92
}