Beispiel #1
0
 public static function setGroupBy($ArGroupBy = array(), $ArHaving = NULL)
 {
     if (!empty($ArGroupBy) && is_array($ArGroupBy)) {
         $ArField = array_keys($ArGroupBy);
         $StTableBy = $ArField[0];
         unset($ArField);
         $StAliasBy = self::FieldTableValidate($StTableBy);
         $StHaving = '';
         if (!empty($ArHaving) && is_array($ArHaving)) {
             if (empty($ArHaving['Alias'])) {
                 $ArField = array_keys($ArHaving);
                 $StTable = $ArField[0];
                 unset($ArField);
                 $StAlias = self::FieldTableValidate($StTable);
                 $StAlias = "{$StAlias}.{$StTable}";
             } else {
                 $StAlias = $ArHaving['Alias'];
             }
             if (empty($ArHaving['Operator']) || count($ArHaving['Operator']) > 4) {
                 throw new Exception(EXC_BAD_ARGUMENT);
             }
             $StOperator = addslashes($ArHaving['Operator']);
             $StValue = addslashes($ArHaving['Value']);
             $StHaving = " HAVING {$StAlias} {$StOperator} {$StValue} ";
         }
         self::$StGroupBy = " GROUP BY {$StAliasBy}.{$ArGroupBy[$StTableBy]} {$StHaving} ";
     }
 }