From 4342d1ac503df7def805f40beb27f717df73361b Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Tue, 4 Jun 2024 21:28:12 -0400 Subject: [PATCH] Add debug to document list --- src/DocumentList.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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;