diff --git a/src/DocumentList.php b/src/DocumentList.php index 60a7658..6aafba2 100644 --- a/src/DocumentList.php +++ b/src/DocumentList.php @@ -46,8 +46,15 @@ class DocumentList */ public function items(): Generator { + $debug = defined('PDO_DOC_DEBUG_SQL'); + if ($this->result) { - while ($row = $this->result->fetch(PDO::FETCH_ASSOC)) yield $this->mapper->map($row); + while ($row = $this->result->fetch(PDO::FETCH_ASSOC)) { + if ($debug) echo "
Returning an item\n
"; + yield $this->mapper->map($row); + } + } else { + if ($debug) echo 'Nothing to return'; } $this->result = null; $this->pdo = null;