Add sub() to the query function builder

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2017-04-12 16:09:35 +02:00
parent 18580395d4
commit ac45af68cd
No known key found for this signature in database
GPG Key ID: CBCA68FBAEBF98C9
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);
}