Skip to content

Commit

Permalink
Merge pull request #91 from nextcloud/counting
Browse files Browse the repository at this point in the history
📦 NEW: support counting of total user_external users
  • Loading branch information
violoncelloCH authored Jun 27, 2019
2 parents 138973d + a1bcefa commit 51556d9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,23 @@ public function userExists($uid) {

return $users > 0;
}

/**
* Count the number of users.
*
* @return int|bool The number of users on success false on failure
*/
public function countUsers() {
$connection = \OC::$server->getDatabaseConnection();
$query = $connection->getQueryBuilder();
$query->select($query->func()->count('*', 'num_users'))
->from('users_external')
->where($query->expr()->eq('backend', $query->createNamedParameter($this->backend)));
$result = $query->execute();
$users = $result->fetchColumn();
$result->closeCursor();

return $users > 0;
}

}

0 comments on commit 51556d9

Please sign in to comment.