diff options
author | Robin Appelman <robin@icewind.nl> | 2019-10-25 16:55:08 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2019-11-13 11:30:32 +0100 |
commit | ac209cea52e81ac07a520a867da4c6906b640df7 (patch) | |
tree | 3f5589e2bf223e9917c45d56297bb56522b58e8f /lib | |
parent | 0e9feeb0900552aa34abd51bbc9454c5e527278f (diff) | |
download | nextcloud-server-ac209cea52e81ac07a520a867da4c6906b640df7.tar.gz nextcloud-server-ac209cea52e81ac07a520a867da4c6906b640df7.zip |
add count() as shortcut for count('*') in FunctionBuilder
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php | 5 | ||||
-rw-r--r-- | lib/public/DB/QueryBuilder/IFunctionBuilder.php | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php index 3b67661c8b0..46bb536dfd2 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php @@ -72,9 +72,10 @@ class FunctionBuilder implements IFunctionBuilder { return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); } - public function count($count, $alias = '') { + public function count($count = '', $alias = '') { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; - return new QueryFunction('COUNT(' . $this->helper->quoteColumnName($count) . ')' . $alias); + $quotedName = $count === '' ? '*' : $this->helper->quoteColumnName($count); + return new QueryFunction('COUNT(' . $quotedName . ')' . $alias); } public function max($field) { diff --git a/lib/public/DB/QueryBuilder/IFunctionBuilder.php b/lib/public/DB/QueryBuilder/IFunctionBuilder.php index 066be470150..861a576914a 100644 --- a/lib/public/DB/QueryBuilder/IFunctionBuilder.php +++ b/lib/public/DB/QueryBuilder/IFunctionBuilder.php @@ -104,7 +104,7 @@ interface IFunctionBuilder { * @return IQueryFunction * @since 14.0.0 */ - public function count($count, $alias = ''); + public function count($count = '', $alias = ''); /** * Takes the maximum of all rows in a column |