[*] BO : Allow complex GROUP BY in SQL Manager

This commit is contained in:
Grégoire Bélorgey committed 2013-10-02 10:31:41 +02:00
1 parent f4c2bacea3
commit dbc5c4301f
1 file changed
+5 -4
+5 -4
View File
@@ -245,9 +245,10 @@ class RequestSqlCore extends ObjectModel
*/ */
public function cutAttribute($attr, $from) 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)) if (!$table = $this->returnNameTable($tab[0], $from))
return false; return false;
else else
@@ -256,9 +257,9 @@ class RequestSqlCore extends ObjectModel
'attribut' => $tab[1], 'attribut' => $tab[1],
'string' => $attr); '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)) if (!$table = $this->returnNameTable(false, $from))
return false; return false;
else else