Passed
Push — master ( 8a002b...c640bb )
by Wilmer
05:52 queued 01:51
created

Transaction::rollBackSavepoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql;
6
7
use Throwable;
8
use Yiisoft\Db\Driver\PDO\AbstractTransactionPDO;
9
use Yiisoft\Db\Exception\Exception;
10
use Yiisoft\Db\Exception\InvalidConfigException;
11
12
/**
13
 * Implements the MSSQL Server specific transaction.
14
 */
15
final class Transaction extends AbstractTransactionPDO
16
{
17
    /**
18
     * Creates a new savepoint.
19
     *
20
     * @param string $name the savepoint name.
21
     *
22
     * @throws Exception|InvalidConfigException|Throwable
23
     */
24 5
    public function createSavepoint(string $name): void
25
    {
26 5
        $this->db->createCommand("SAVE TRANSACTION $name")->execute();
27
    }
28
29
    /**
30
     * Releases an existing savepoint.
31
     *
32
     * @param string $name the savepoint name.
33
     */
34 1
    public function releaseSavepoint(string $name): void
35
    {
36
        // does nothing as MSSQL doesn't support this
37 1
    }
38
39
    /**
40
     * Rolls back to a before created savepoint.
41
     *
42
     * @param string $name the savepoint name.
43
     *
44
     * @throws Exception|InvalidConfigException|Throwable
45
     */
46 2
    public function rollBackSavepoint(string $name): void
47
    {
48 2
        $this->db->createCommand("ROLLBACK TRANSACTION $name")->execute();
49
    }
50
}
51