diff --git a/library/Zend/Db/Select.php b/library/Zend/Db/Select.php index 892281127b..6de561dae8 100644 --- a/library/Zend/Db/Select.php +++ b/library/Zend/Db/Select.php @@ -515,7 +515,7 @@ public function group($spec) } foreach ($spec as $val) { - if (preg_match('/^[\w]*\([^\)]*\)$/', (string) $val)) { + if (preg_match('/^([\w]*\(([^\)]|(?1))*\))$/', (string) $val)) { $val = new Zend_Db_Expr($val); } $this->_parts[self::GROUP][] = $val; @@ -607,7 +607,7 @@ public function order($spec) $val = trim($matches[1]); $direction = $matches[2]; } - if (preg_match('/^[\w]*\([^\)]*\)$/', $val)) { + if (preg_match('/^([\w]*\(([^\)]|(?1))*\))$/', (string) $val)) { $val = new Zend_Db_Expr($val); } $this->_parts[self::ORDER][] = array($val, $direction); @@ -949,7 +949,7 @@ protected function _tableCols($correlationName, $cols, $afterCorrelationName = n $alias = $m[2]; } // Check for columns that look like functions and convert to Zend_Db_Expr - if (preg_match('/^[\w]*\([^\)]*\)$/', $col)) { + if (preg_match('/^([\w]*\(([^\)]|(?1))*\))$/', (string) $col)) { $col = new Zend_Db_Expr($col); } elseif (preg_match('/(.+)\.(.+)/', $col, $m)) { $currentCorrelationName = $m[1];