aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/ResultAdapter.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-06-28 15:57:35 +0200
committerJoas Schilling <coding@schilljs.com>2024-07-19 11:21:12 +0200
commit11e84b89688abea9c7fdb16d92af0d1485fda436 (patch)
treefc2580e54683d6e9f128e6801b57d27a479b3cef /lib/private/DB/ResultAdapter.php
parenta4c1d7291f68423c719ace177ea9a94203b31845 (diff)
downloadnextcloud-server-11e84b89688abea9c7fdb16d92af0d1485fda436.tar.gz
nextcloud-server-11e84b89688abea9c7fdb16d92af0d1485fda436.zip
fix(db): Fix internal calls to doctrine's `fetch()` methods
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/DB/ResultAdapter.php')
-rw-r--r--lib/private/DB/ResultAdapter.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/private/DB/ResultAdapter.php b/lib/private/DB/ResultAdapter.php
index 8b004d471ec..95a7620e0ff 100644
--- a/lib/private/DB/ResultAdapter.php
+++ b/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) {