@@ 126-145 (lines=20) @@ | ||
123 | /** |
|
124 | * コミットする |
|
125 | */ |
|
126 | public function commit() |
|
127 | { |
|
128 | try { |
|
129 | if ($this->connection !== null) { |
|
130 | if ($this->inTransaction()) { |
|
131 | $this->connection->commit(); |
|
132 | $this->logger->debug("Execute commit."); |
|
133 | } else { |
|
134 | $this->logger->warn("Not executed commit because the transaction is not started."); |
|
135 | } |
|
136 | } else { |
|
137 | throw new DatabaseException("Can't execute commit."); |
|
138 | } |
|
139 | } catch (\PDOException $e) { |
|
140 | $this->query = null; |
|
141 | throw new DatabaseException($e); |
|
142 | } finally { |
|
143 | $this->disconnect(); |
|
144 | } |
|
145 | } |
|
146 | ||
147 | /** |
|
148 | * ロールバックする |
|
@@ 150-169 (lines=20) @@ | ||
147 | /** |
|
148 | * ロールバックする |
|
149 | */ |
|
150 | public function rollback() |
|
151 | { |
|
152 | try { |
|
153 | if ($this->connection !== null) { |
|
154 | if ($this->inTransaction()) { |
|
155 | $this->connection->rollback(); |
|
156 | $this->logger->debug("Execute rollback."); |
|
157 | } else { |
|
158 | $this->logger->warn("Not executed rollback because the transaction is not started."); |
|
159 | } |
|
160 | } else { |
|
161 | throw new DatabaseException("Can't execute rollback."); |
|
162 | } |
|
163 | } catch (\PDOException $e) { |
|
164 | $this->query = null; |
|
165 | throw new DatabaseException($e); |
|
166 | } finally { |
|
167 | $this->disconnect(); |
|
168 | } |
|
169 | } |
|
170 | ||
171 | /** |
|
172 | * ロールバックが発生したかどうか |