Skip to content

Commit

Permalink
Unset prior fetched rows
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jun 28, 2018
1 parent 0c6631e commit 419279e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Internal/ResultProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function setColumns(int $columns) {

public function updateState(int $state) {
$this->state = $state;
if ($state == ResultProxy::ROWS_FETCHED) {
if ($state === self::ROWS_FETCHED) {
$this->rowFetched(null);
}
if (empty($this->deferreds[$state])) {
Expand All @@ -51,9 +51,9 @@ public function rowFetched($row) {
if ($row !== null) {
$this->rows[$this->fetchedRows++] = $row;
}
list($entry, , $cb) = current($this->deferreds[ResultProxy::SINGLE_ROW_FETCH]);
list($entry, , $cb) = current($this->deferreds[self::SINGLE_ROW_FETCH]);
if ($entry !== null) {
unset($this->deferreds[ResultProxy::SINGLE_ROW_FETCH][key($this->deferreds[ResultProxy::SINGLE_ROW_FETCH])]);
unset($this->deferreds[self::SINGLE_ROW_FETCH][key($this->deferreds[self::SINGLE_ROW_FETCH])]);
$entry->resolve($cb && $row ? $cb($row) : $row);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ public function getCurrent() {

private static function fetchRow(Internal\ResultProxy $result): Promise {
if ($result->userFetched < $result->fetchedRows) {
return new Success($result->rows[$result->userFetched++]);
$row = $result->rows[$result->userFetched];
unset($result->rows[$result->userFetched]);
$result->userFetched++;
return new Success($row);
}

if ($result->state === Internal\ResultProxy::ROWS_FETCHED) {
Expand Down

0 comments on commit 419279e

Please sign in to comment.