aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php')
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
index 88290237a90..3384ad8b42f 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
@@ -27,17 +27,22 @@ use OC\DB\QueryBuilder\QueryFunction;
use OC\DB\QueryBuilder\QuoteHelper;
use OCP\DB\QueryBuilder\IFunctionBuilder;
use OCP\DB\QueryBuilder\IQueryFunction;
+use OCP\IDBConnection;
class FunctionBuilder implements IFunctionBuilder {
/** @var QuoteHelper */
protected $helper;
+ /** @var IDBConnection */
+ protected $connection;
+
/**
* ExpressionBuilder constructor.
*
* @param QuoteHelper $helper
*/
- public function __construct(QuoteHelper $helper) {
+ public function __construct(IDBConnection $connection, QuoteHelper $helper) {
+ $this->connection = $connection;
$this->helper = $helper;
}
@@ -49,8 +54,14 @@ class FunctionBuilder implements IFunctionBuilder {
return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')');
}
- public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
- return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . ')');
+ public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction {
+ if (is_null($orderBy)) {
+ $orderByClause = '';
+ } else {
+ $orderByClause = ' ORDER BY ' . $orderBy;
+ }
+ $separator = $this->connection->quote($separator);
+ return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . $orderByClause . ' SEPARATOR ' . $separator . ')');
}
public function substring($input, $start, $length = null): IQueryFunction {