@@ 46-77 (lines=32) @@ | ||
43 | * @param int $count |
|
44 | * @return EventStreamInterface |
|
45 | */ |
|
46 | public function readStreamEvents($streamId, $start = 1, $count = null) |
|
47 | { |
|
48 | if (!isset($count)) { |
|
49 | $count = self::MAX_UNSIGNED_BIG_INT; |
|
50 | } |
|
51 | $stmt = $this->connection->prepare( |
|
52 | 'SELECT * |
|
53 | FROM events |
|
54 | WHERE stream_id = :streamId |
|
55 | LIMIT :limit |
|
56 | OFFSET :offset' |
|
57 | ); |
|
58 | $stmt->bindValue(':streamId', $streamId); |
|
59 | $stmt->bindValue(':offset', (int) $start - 1, \PDO::PARAM_INT); |
|
60 | $stmt->bindValue(':limit', $count, \PDO::PARAM_INT); |
|
61 | $stmt->execute(); |
|
62 | $results = $stmt->fetchAll(); |
|
63 | ||
64 | $storedEvents = array_map(function($result) { |
|
65 | return new StoredEvent( |
|
66 | $result['id'], |
|
67 | $result['stream_id'], |
|
68 | $result['type'], |
|
69 | $result['event'], |
|
70 | $result['metadata'], |
|
71 | new \DateTimeImmutable($result['occurred_on']), |
|
72 | Version::fromString($result['version']) |
|
73 | ); |
|
74 | }, $results); |
|
75 | ||
76 | return $this->domainEventStreamFromStoredEvents($storedEvents); |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * @param string $streamId |
@@ 47-78 (lines=32) @@ | ||
44 | * @param int $count |
|
45 | * @return EventStreamInterface |
|
46 | */ |
|
47 | public function readStreamEvents($streamId, $start = 1, $count = null) |
|
48 | { |
|
49 | if (!isset($count)) { |
|
50 | $count = self::MAX_UNSIGNED_BIG_INT; |
|
51 | } |
|
52 | $stmt = $this->connection->prepare( |
|
53 | 'SELECT * |
|
54 | FROM events |
|
55 | WHERE stream_id = :streamId |
|
56 | LIMIT :limit |
|
57 | OFFSET :offset' |
|
58 | ); |
|
59 | $stmt->bindValue(':streamId', $streamId); |
|
60 | $stmt->bindValue(':offset', (int) $start - 1, \PDO::PARAM_INT); |
|
61 | $stmt->bindValue(':limit', $count, \PDO::PARAM_INT); |
|
62 | $stmt->execute(); |
|
63 | $results = $stmt->fetchAll(); |
|
64 | ||
65 | $storedEvents = array_map(function($event) { |
|
66 | return new StoredEvent( |
|
67 | $event['id'], |
|
68 | $event['stream_id'], |
|
69 | $event['type'], |
|
70 | $event['event'], |
|
71 | $event['metadata'], |
|
72 | new \DateTimeImmutable($event['occurred_on']), |
|
73 | Version::fromString($event['version']) |
|
74 | ); |
|
75 | }, $results); |
|
76 | ||
77 | return $this->domainEventStreamFromStoredEvents($storedEvents); |
|
78 | } |
|
79 | ||
80 | /** |
|
81 | * @param string $streamId |