Drop Table before returning from function
[civicrm-core.git] / CRM / Report / Form.php
index 409ad8323d998e402d8e824e6eb82e1ad03ea025..9149554ba9617e343bc87a34b98058deca83e349 100644 (file)
@@ -361,6 +361,12 @@ class CRM_Report_Form extends CRM_Core_Form {
   public $_orderBy = NULL;
   public $_orderByFields = array();
   public $_orderByArray = array();
+  /**
+   * Array of clauses to group by.
+   *
+   * @var array
+   */
+  protected $_groupByArray = array();
   public $_groupBy = NULL;
   public $_whereClauses = array();
   public $_havingClauses = array();
@@ -2637,7 +2643,6 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
    * Build group by clause.
    */
   public function groupBy() {
-    $groupBys = array();
     if (!empty($this->_params['group_bys']) &&
       is_array($this->_params['group_bys'])
     ) {
@@ -2645,15 +2650,15 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
         if (array_key_exists('group_bys', $table)) {
           foreach ($table['group_bys'] as $fieldName => $field) {
             if (!empty($this->_params['group_bys'][$fieldName])) {
-              $groupBys[] = $field['dbAlias'];
+              $this->_groupByArray[] = $field['dbAlias'];
             }
           }
         }
       }
     }
 
-    if (!empty($groupBys)) {
-      $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBys);
+    if (!empty($this->_groupByArray)) {
+      $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $this->_groupByArray);
     }
   }