diff --git a/src/Custom.php b/src/Custom.php index b3ce240..fc1a068 100644 --- a/src/Custom.php +++ b/src/Custom.php @@ -26,7 +26,13 @@ class Custom $stmt = $pdo->prepare($query); foreach ($parameters as $key => $value) { if ($debug) echo "
Binding $value to $key\n"; - $stmt->bindValue($key, $value); + $dataType = match (true) { + is_bool($value) => PDO::PARAM_BOOL, + is_int($value) => PDO::PARAM_INT, + is_null($value) => PDO::PARAM_NULL, + default => PDO::PARAM_STR + }; + $stmt->bindValue($key, $value, $dataType); } if ($debug) echo '
SQL: ' . $stmt->queryString . ''; if ($stmt->execute()) return $stmt; diff --git a/src/DocumentList.php b/src/DocumentList.php index da5d0f3..60a7658 100644 --- a/src/DocumentList.php +++ b/src/DocumentList.php @@ -22,7 +22,7 @@ class DocumentList * @param PDOStatement|null $result The result of the query * @param Mapper
Returning an item\n"; - yield $this->mapper->map($row); - } - } else { - if ($debug) echo 'Nothing to return'; + while ($row = $this->result->fetch(PDO::FETCH_ASSOC)) yield $this->mapper->map($row); } $this->result = null; $this->pdo = null;