Oracle does not support PDO::FETCH_KEY_PAIR

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-07-20 20:13:35 +02:00
parent 690ef25928
commit daa3cfcb70
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with 13 additions and 6 deletions

View File

@ -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;
}
/**