From: Joas Schilling Date: Thu, 20 Jul 2017 18:13:35 +0000 (+0200) Subject: Oracle does not support PDO::FETCH_KEY_PAIR X-Git-Tag: v12.0.3RC1~88^2~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=daa3cfcb7087c7f116cce9d62f58066029139692;p=nextcloud-server.git Oracle does not support PDO::FETCH_KEY_PAIR Signed-off-by: Joas Schilling --- diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index f1c5b7dca50..6a8e79b496b 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -411,9 +411,12 @@ class Manager implements ICommentsManager { */ public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) { $qb = $this->dbConn->getQueryBuilder(); - $query = $qb->select('fileid', $qb->createFunction( - 'COUNT(' . $qb->getColumnName('c.id') . ')') - )->from('comments', 'c') + $query = $qb->select('fileid') + ->selectAlias( + $qb->createFunction('COUNT(' . $qb->getColumnName('c.id') . ')'), + 'num_ids' + ) + ->from('comments', 'c') ->innerJoin('c', 'filecache', 'f', $qb->expr()->andX( $qb->expr()->eq('c.object_type', $qb->createNamedParameter('files')), $qb->expr()->eq('f.fileid', $qb->expr()->castColumn('c.object_id', IQueryBuilder::PARAM_INT)) @@ -431,9 +434,13 @@ class Manager implements ICommentsManager { ->groupBy('f.fileid'); $resultStatement = $query->execute(); - return array_map(function ($count) { - return (int)$count; - }, $resultStatement->fetchAll(\PDO::FETCH_KEY_PAIR)); + + $results = []; + while ($row = $resultStatement->fetch()) { + $results[$row['fileid']] = (int) $row['num_ids']; + } + $resultStatement->closeCursor(); + return $results; } /**