From dbc5c4301f8852d65802eb9b605627a8b17ee432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20B=C3=A9lorgey?= Date: Wed, 2 Oct 2013 10:31:41 +0200 Subject: [PATCH] [*] BO : Allow complex GROUP BY in SQL Manager --- classes/RequestSql.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/classes/RequestSql.php b/classes/RequestSql.php index 27c0b966f..dee32055f 100644 --- a/classes/RequestSql.php +++ b/classes/RequestSql.php @@ -245,9 +245,10 @@ class RequestSqlCore extends ObjectModel */ public function cutAttribute($attr, $from) { - if (preg_match('#^((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))\.((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))$#i', $attr)) + $matches = array(); + if (preg_match('/((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))\.((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))$/i', $attr, $matches, PREG_OFFSET_CAPTURE)) { - $tab = explode('.', str_replace(array('`', '(', ')'), '', $attr)); + $tab = explode('.', str_replace(array('`', '(', ')'), '', $matches[0][0])); if (!$table = $this->returnNameTable($tab[0], $from)) return false; else @@ -256,9 +257,9 @@ class RequestSqlCore extends ObjectModel 'attribut' => $tab[1], 'string' => $attr); } - elseif (preg_match('#^((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))$#i', $attr)) + elseif (preg_match('/((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))$/i', $attr, $matches, PREG_OFFSET_CAPTURE)) { - $attribut = str_replace(array('`', '(', ')'), '', $attr); + $attribut = str_replace(array('`', '(', ')'), '', $matches[0][0]); if (!$table = $this->returnNameTable(false, $from)) return false; else