Merge pull request #4331 from nextcloud/query-builder-sum

Add sum() to the query function builder
This commit is contained in:
Morris Jobke 2017-04-12 12:55:09 -05:00 committed by GitHub
commit 124fdf8062
2 changed files with 14 additions and 0 deletions

View File

@ -53,4 +53,8 @@ class FunctionBuilder implements IFunctionBuilder {
return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')');
}
}
public function sum($field) {
return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')');
}
}

View File

@ -59,4 +59,14 @@ interface IFunctionBuilder {
* @since 12.0.0
*/
public function substring($input, $start, $length = null);
/**
* Takes the sum of all rows in a column
*
* @param mixed $field the column to sum
*
* @return IQueryFunction
* @since 12.0.0
*/
public function sum($field);
}