Skip to content

Commit

Permalink
no issue - make tests and result great again
Browse files Browse the repository at this point in the history
  • Loading branch information
pounard committed Mar 1, 2024
1 parent 1c2f5b8 commit 9f550ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Bridge/Pdo/PdoQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ protected function doExecuteQuery(string $expression, array $arguments = []): Re
$this->dieIfClosed();

$statement = $this->connection->prepare($expression, [\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY]);
$statement->setFetchMode(\PDO::FETCH_ASSOC);
$statement->execute($arguments);

$result = new IterableResult(
Expand Down
5 changes: 5 additions & 0 deletions src/Result/AbstractResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ protected function fetchNext(): null|array
/**
* Get column value in row.
*
* Warning: for this method to work with PDO, fetch mode must be set
* to \PDO::FETCH_ASSOC, other wise columns count and order may vary
* and cause unpredictable results.
*
* @return mixed $value
* Whatever is the row value, or null if no value found.
*/
Expand All @@ -445,6 +449,7 @@ protected function getColumnValue(?array $row, int|string $name = 0): mixed
if ($name >= $this->columnCount()) {
throw new ResultError(\sprintf("Column with index %d does not exist in result.", $name));
}

return \array_values($row)[$name];
}

Expand Down

0 comments on commit 9f550ca

Please sign in to comment.