Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5namespace PeServer\Core\Database;
6
7use PDOException;
8use PeServer\Core\Database\IDatabaseContext;
9use PeServer\Core\IDisposable;
10use PeServer\Core\Throws\DatabaseException;
11use PeServer\Core\Throws\SqlException;
12use PeServer\Core\Throws\TransactionException;
13
14/**
15 * トランザクションをサポートする状態。
16 */
17interface IDatabaseTransactionContext extends IDatabaseContext, IDisposable
18{
19    #region function
20
21    /**
22     * トランザクション開始。
23     *
24     * @return void
25     * @throws TransactionException
26     */
27    public function beginTransaction(): void;
28
29    /**
30     * トランザクションの確定。
31     *
32     * @return void
33     * @throws TransactionException
34     */
35    public function commit(): void;
36
37    /**
38     * トランザクションの取消。
39     *
40     * @return void
41     * @throws TransactionException
42     */
43    public function rollback(): void;
44
45    /**
46     * トランザクションラップ処理。
47     *
48     * @param callable(IDatabaseContext $context): bool $callback 実際の処理。戻り値が真の場合にコミット、偽ならロールバック。
49     * @return bool コミットされたか。正常系としてのコミット・ロールバック処理の戻りであり、異常系は例外が投げられる。
50     * @throws DatabaseException
51     */
52    public function transaction(callable $callback): bool;
53
54    #endregion
55}