diff options
author | Joas Schilling <coding@schilljs.com> | 2018-10-19 16:44:28 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-11-08 15:44:45 +0100 |
commit | bb352fb667e87ea0829f1da5f9e85c34bdefe9fa (patch) | |
tree | cd243856dcfec5708528418b55269e3d7feed53a /lib/private/Comments | |
parent | 78fd8ab0fd362fd5d568dfc5b47a02158e62d51c (diff) | |
download | nextcloud-server-bb352fb667e87ea0829f1da5f9e85c34bdefe9fa.tar.gz nextcloud-server-bb352fb667e87ea0829f1da5f9e85c34bdefe9fa.zip |
Use the defined func()->count() instead of manual counting
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r-- | lib/private/Comments/Manager.php | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index e9bb001f77d..f3865c6504f 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -163,7 +163,7 @@ class Manager implements ICommentsManager { */ protected function updateChildrenInformation($id, \DateTime $cDateTime) { $qb = $this->dbConn->getQueryBuilder(); - $query = $qb->select($qb->createFunction('COUNT(' . $qb->getColumnName('id') . ')')) + $query = $qb->select($qb->func()->count('id')) ->from('comments') ->where($qb->expr()->eq('parent_id', $qb->createParameter('id'))) ->setParameter('id', $id); @@ -552,7 +552,7 @@ class Manager implements ICommentsManager { */ public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null, $verb = '') { $qb = $this->dbConn->getQueryBuilder(); - $query = $qb->select($qb->createFunction('COUNT(' . $qb->getColumnName('id') . ')')) + $query = $qb->select($qb->func()->count('id')) ->from('comments') ->where($qb->expr()->eq('object_type', $qb->createParameter('type'))) ->andWhere($qb->expr()->eq('object_id', $qb->createParameter('id'))) @@ -585,10 +585,7 @@ class Manager implements ICommentsManager { public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) { $qb = $this->dbConn->getQueryBuilder(); $query = $qb->select('f.fileid') - ->selectAlias( - $qb->createFunction('COUNT(' . $qb->getColumnName('c.id') . ')'), - 'num_ids' - ) + ->addSelect($qb->func()->count('c.id', 'num_ids')) ->from('comments', 'c') ->innerJoin('c', 'filecache', 'f', $qb->expr()->andX( $qb->expr()->eq('c.object_type', $qb->createNamedParameter('files')), |