Changes for beta10 (#5)
- Add In/InArray support - Add ORDER BY support for `Find` functions - Update dependencies - Implement fixes identified via static analysis Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
@@ -35,10 +35,12 @@ class DocumentList
|
||||
*/
|
||||
private function __construct(private ?PDOStatement &$result, private readonly Mapper $mapper)
|
||||
{
|
||||
if ($row = $this->result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$this->first = $this->mapper->map($row);
|
||||
} else {
|
||||
$this->result = null;
|
||||
if (!is_null($this->result)) {
|
||||
if ($row = $this->result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$this->first = $this->mapper->map($row);
|
||||
} else {
|
||||
$this->result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +69,11 @@ class DocumentList
|
||||
$this->isConsumed = true;
|
||||
return;
|
||||
}
|
||||
if (!$this->first) {
|
||||
$this->isConsumed = true;
|
||||
$this->result = null;
|
||||
return;
|
||||
}
|
||||
yield $this->first;
|
||||
while ($row = $this->result->fetch(PDO::FETCH_ASSOC)) {
|
||||
yield $this->mapper->map($row);
|
||||
@@ -133,14 +140,14 @@ class DocumentList
|
||||
* Construct a new document list
|
||||
*
|
||||
* @param string $query The query to run to retrieve results
|
||||
* @param array $parameters An associative array of parameters for the query
|
||||
* @param array<string, mixed> $parameters An associative array of parameters for the query
|
||||
* @param Mapper<TDoc> $mapper A mapper to deserialize JSON documents
|
||||
* @return static The document list instance
|
||||
* @return self<TDoc> The document list instance
|
||||
* @throws DocumentException If any is encountered
|
||||
*/
|
||||
public static function create(string $query, array $parameters, Mapper $mapper): static
|
||||
public static function create(string $query, array $parameters, Mapper $mapper): self
|
||||
{
|
||||
$stmt = &Custom::runQuery($query, $parameters);
|
||||
return new static($stmt, $mapper);
|
||||
return new self($stmt, $mapper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user