Skip to content

Commit

Permalink
Merge pull request #85 from nextcloud/backport/84/proper-column-name-…
Browse files Browse the repository at this point in the history
…escaping

[stable14] Properly escape column name in "createFunction" call
  • Loading branch information
rullzer authored Oct 19, 2018
2 parents 033f72c + 18040d4 commit 34f152b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Categories/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ protected function countStorages($type) {
* @return int
*/
protected function countEntries($tableName, $column = '*') {
$query = $this->connection->getQueryBuilder();

if ($column !== '*') {
$column = 'DISTINCT(' . $column . ')';
$column = 'DISTINCT(' . $query->getColumnName($column ) . ')';
}

$query = $this->connection->getQueryBuilder();
$query->selectAlias($query->createFunction('COUNT(' . $column . ')'), 'num_entries')
->from($tableName);
$result = $query->execute();
Expand Down

0 comments on commit 34f152b

Please sign in to comment.