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