Skip to content

Commit d23af96

Browse files
Optimization: don't run the last query if there are no results left.
1 parent df425c5 commit d23af96

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ORM/ResultSet.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ public function next()
170170
public function rewind()
171171
{
172172
$this->index = 0;
173-
$this->chunkIndex = 0;
174173
$this->page = 1;
174+
$this->chunkIndex = 0;
175+
$this->chunkSize = 0;
175176
}
176177

177178
/**
@@ -188,6 +189,10 @@ public function valid()
188189
}
189190

190191
if ($this->chunkSize && $this->chunkIndex >= $this->chunkSize) {
192+
if ($this->chunkIndex < $this->getConfig('size')) {
193+
return false;
194+
}
195+
191196
$this->page++;
192197
$this->fetchChunk();
193198
}

0 commit comments

Comments
 (0)