Merge pull request #4331 from nextcloud/query-builder-sum
Add sum() to the query function builder
This commit is contained in:
commit
124fdf8062
|
@ -53,4 +53,8 @@ class FunctionBuilder implements IFunctionBuilder {
|
||||||
return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')');
|
return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sum($field) {
|
||||||
|
return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,4 +59,14 @@ interface IFunctionBuilder {
|
||||||
* @since 12.0.0
|
* @since 12.0.0
|
||||||
*/
|
*/
|
||||||
public function substring($input, $start, $length = null);
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue