From 07e51a719a29e8ab9110b31d85f57031f6c66c77 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 17 Nov 2016 14:04:07 +0100 Subject: Allow aliasing columns when using the query builder Signed-off-by: Robin Appelman --- lib/private/DB/QueryBuilder/QuoteHelper.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/private/DB') diff --git a/lib/private/DB/QueryBuilder/QuoteHelper.php b/lib/private/DB/QueryBuilder/QuoteHelper.php index 6d15cec5a05..041718bce5a 100644 --- a/lib/private/DB/QueryBuilder/QuoteHelper.php +++ b/lib/private/DB/QueryBuilder/QuoteHelper.php @@ -61,6 +61,11 @@ class QuoteHelper { throw new \InvalidArgumentException('Only strings, Literals and Parameters are allowed'); } + $string = str_replace(' AS ', ' as ', $string); + if (substr_count($string, ' as ')) { + return implode(' as ', array_map([$this, 'quoteColumnName'], explode(' as ', $string, 2))); + } + if (substr_count($string, '.')) { list($alias, $columnName) = explode('.', $string, 2); -- cgit v1.2.3