| @@ 165-170 (lines=6) @@ | ||
| 162 | protected function appendStoredEvents($streamId, $storedEvents, $expectedVersion) |
|
| 163 | { |
|
| 164 | $this->connection->transactional(function() use ($streamId, $storedEvents, $expectedVersion) { |
|
| 165 | if (!$this->streamExists($streamId)) { |
|
| 166 | $stmt = $this->connection |
|
| 167 | ->prepare('INSERT INTO streams (id) VALUES (:streamId)'); |
|
| 168 | $stmt->bindValue(':streamId', $streamId); |
|
| 169 | $stmt->execute(); |
|
| 170 | } |
|
| 171 | foreach ($storedEvents as $storedEvent) { |
|
| 172 | $stmt = $this->connection->prepare( |
|
| 173 | 'INSERT INTO events (stream_id, type, event, metadata, occurred_on, version) |
|
| @@ 135-140 (lines=6) @@ | ||
| 132 | { |
|
| 133 | $this->connection->beginTransaction(); |
|
| 134 | try { |
|
| 135 | if (!$this->streamExists($streamId)) { |
|
| 136 | $stmt = $this->connection |
|
| 137 | ->prepare('INSERT INTO streams (id) VALUES (:streamId)'); |
|
| 138 | $stmt->bindValue(':streamId', $streamId); |
|
| 139 | $stmt->execute(); |
|
| 140 | } |
|
| 141 | foreach ($storedEvents as $storedEvent) { |
|
| 142 | $stmt = $this->connection->prepare( |
|
| 143 | 'INSERT INTO events (stream_id, type, event, metadata, occurred_on, version) |
|