Skip to content

Commit

Permalink
Merge pull request #44 from kinglozzer/generators
Browse files Browse the repository at this point in the history
Update SQLite3Query to use generators
  • Loading branch information
dhensby authored Mar 19, 2018
2 parents dbc0fb7 + 139c2b0 commit 9c4de41
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions code/SQLite3Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@ public function __destruct()
}
}

public function seek($row)
public function getIterator()
{
$this->handle->reset();
$i=0;
while ($i <= $row && $result = @$this->handle->fetchArray(SQLITE3_ASSOC)) {
$i++;
while ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
yield $data;
}
return $result;
}

/**
Expand All @@ -66,13 +63,4 @@ public function numRecords()
$this->handle->reset();
return $c;
}

public function nextRecord()
{
if ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
return $data;
} else {
return false;
}
}
}

0 comments on commit 9c4de41

Please # to comment.