1 | <?php |
||
14 | class Transaction |
||
15 | { |
||
16 | const STATE_NULL = 'null'; |
||
17 | const STATE_STARTED = 'started'; |
||
18 | const STATE_ROLLBACKED = 'rollbacked'; |
||
19 | const STATE_COMMITTED = 'committed'; |
||
20 | const STATE_ERRORED = 'errored'; |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | * @param \Zend\Db\Adapter\Adapter $adapter |
||
25 | */ |
||
26 | protected $adapter; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * |
||
31 | * @var string state of current transaction |
||
32 | */ |
||
33 | protected $state; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * |
||
38 | * @param \Zend\Db\Adapter\Adapter $adapter |
||
39 | */ |
||
40 | 3 | public function __construct(Adapter $adapter) |
|
45 | |||
46 | /** |
||
47 | * Start a new transaction |
||
48 | * |
||
49 | * @throws Exception\TransactionException |
||
50 | * @return Transaction |
||
51 | */ |
||
52 | 3 | public function start() |
|
65 | |||
66 | /** |
||
67 | * Commit changes |
||
68 | * |
||
69 | * @throws Exception\TransactionException |
||
70 | * @return Transaction |
||
71 | */ |
||
72 | 2 | public function commit() |
|
84 | |||
85 | /** |
||
86 | * Rollback transaction |
||
87 | * |
||
88 | * @throws Exception\TransactionException |
||
89 | * @return Transaction |
||
90 | */ |
||
91 | 3 | public function rollback() |
|
103 | } |
||
104 |