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/private/DB/QueryBuilder | |
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/private/DB/QueryBuilder')
-rw-r--r-- | lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php | 5 |
1 files changed, 3 insertions, 2 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) { |