From 139c2b0ba624dd7b57db8a35f6ea6c6240fc4fd8 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Fri, 16 Mar 2018 16:47:48 +0000 Subject: [PATCH] Update SQLite3Query to use generators --- code/SQLite3Query.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/code/SQLite3Query.php b/code/SQLite3Query.php index e29a88d..82a5ac7 100644 --- a/code/SQLite3Query.php +++ b/code/SQLite3Query.php @@ -43,14 +43,11 @@ class SQLite3Query extends Query } } - 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; } /** @@ -66,13 +63,4 @@ class SQLite3Query extends Query $this->handle->reset(); return $c; } - - public function nextRecord() - { - if ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) { - return $data; - } else { - return false; - } - } }