fix(db): Fix internal calls to doctrine's `fetch()` methods

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/46605/head
Joas Schilling 2 years ago
parent a4c1d7291f
commit 11e84b8968
No known key found for this signature in database
GPG Key ID: 74434EFE0D2E2205
  1. 17
      lib/private/DB/ResultAdapter.php

@ -30,14 +30,21 @@ class ResultAdapter implements IResult {
}
public function fetch(int $fetchMode = PDO::FETCH_ASSOC) {
return $this->inner->fetch($fetchMode);
return match ($fetchMode) {
PDO::FETCH_ASSOC => $this->inner->fetchAssociative(),
PDO::FETCH_NUM => $this->inner->fetchNumeric(),
PDO::FETCH_COLUMN => $this->inner->fetchOne(),
default => throw new \Exception('Fetch mode needs to be assoc, num or column.'),
};
}
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array {
if ($fetchMode !== PDO::FETCH_ASSOC && $fetchMode !== PDO::FETCH_NUM && $fetchMode !== PDO::FETCH_COLUMN) {
throw new \Exception('Fetch mode needs to be assoc, num or column.');
}
return $this->inner->fetchAll($fetchMode);
return match ($fetchMode) {
PDO::FETCH_ASSOC => $this->inner->fetchAllAssociative(),
PDO::FETCH_NUM => $this->inner->fetchAllNumeric(),
PDO::FETCH_COLUMN => $this->inner->fetchFirstColumn(),
default => throw new \Exception('Fetch mode needs to be assoc, num or column.'),
};
}
public function fetchColumn($columnIndex = 0) {

Loading…
Cancel
Save